Yii Framework Forum: to connect yii2 with database apache cassandra - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

to connect yii2 with database apache cassandra i want to know haw to connect my yii2 project to my database cassandra Rate Topic: -----

#1 User is offline   bergerbanga 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 24-January 18

Posted 24 January 2018 - 05:42 PM

i want to know haw to connect my yii2 project to my database server apache cassandra. when i use yii2-cassandra-cql,i have this erro.(see error.png).
that is the components of my main-local file.

<?php
return [
    'components' => array(
        /*'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],*/
        'cassandra' => array(
            'class' => 'beliy\cassandra\Connection',
            'keyspace' => 'Systemecomptable',
            'servers' => array('127.0.0.1:9042'),
        ),

    )
];

// my test in controller

public function actionSignup()
    {
//
        $cass = Yii::$app->cassandra;
        $cql = 'SELECT * FROM plancomptable_by_entreprise WHERE id_entr=967503a9-d6c8-4987-b326-f39f90e78a9b';
        $query_result = $cass->cql3Query($cql);
        $rows = $cass->cqlGetRows($query_result);

//
        $model = new SignupForm();
        if ($model->load(Yii::$app->request->post())) {
            if ($user = $model->signup()) {
                if (Yii::$app->getUser()->login($user)) {
                    return $this->goHome();
                }
            }
        }

        return $this->render('signup', [
            'model' => $model,
        ]);
    }


thank you
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,546
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 25 January 2018 - 12:37 AM

I would suggest you use the ext provided by the datastax folks, someone asked this questions some time ago I created a gist with an example based on datastax/php-driver here is link

https://gist.github....72bb3b792b8b58d
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users