Yii Framework Forum: Csqldataprovider Diferent Connection.... - Yii Framework Forum

Jump to content

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

Csqldataprovider Diferent Connection.... Rate Topic: -----

#1 User is offline   yiiqs2 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 21-August 13

Posted 02 September 2013 - 11:59 PM

Hi all...

i have cdbconnection to connect sphinx server like this :

$dsn = 'mysql:dbname=catalog;host=127.0.0.1;port=9306;';
$port='9306';
$connection=new CDbConnection($dsn);
$connection->active=true;



i wanna use CSqlDataProvider to show data from sphinx to datagrid.
$sqlStatement="select * from catalog where match('@value oracle')";
$dataProvidersphinx = new CSqlDataProvider($sqlStatement, array(
                    'keyField' => $key,
                    //'totalItemCount' => $count,
                    'sort' => array(
                        'attributes' => array(
                            'entry', 'value',
                        ),
                    ),
                    'pagination' => array(
                        'pageSize' => 10,
                    ),
                ));

but i get error cause connection still use mysql not sphinx
Syntax error or access violation

my question : how to use my cdbconnection to execute CSqlDataProvider,... ??

Thanks.
0

#2 User is offline   BlkRaven 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 26-January 11

Posted 03 September 2013 - 01:47 AM

There's a tutorial at

http://www.yiiframew...support-in-yii/

on how to use multiple databases with Yii.
0

#3 User is offline   yiiqs2 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 21-August 13

Posted 03 September 2013 - 09:21 AM

View PostBlkRaven, on 03 September 2013 - 01:47 AM, said:

There's a tutorial at

http://www.yiiframew...support-in-yii/

on how to use multiple databases with Yii.



Thanks BlkRaven .

i solved using this.

$dataProvidersphinx->db = $connection;


0

#4 User is offline   jerome nicholas 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 18-April 11

Posted 30 October 2017 - 02:58 AM

$sqlStatement="select * from catalog where match('@value oracle')";
$dataProvidersphinx = new CSqlDataProvider($sqlStatement, array(
'db' => Yii::app()->dbSphinx, // main.php config file

'keyField' => $key,
//'totalItemCount' => $count,
'sort' => array(
'attributes' => array(
'entry', 'value',
),
),
'pagination' => array(
'pageSize' => 10,
),
));
Jerome Nicholas
Software Developer
Shalom Software, Melbourne
http://www.shalomsoftware.com.au
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