Csqldataprovider Diferent Connection....

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

[color="#FF0000"]Syntax error or access violation[/color]

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

Thanks.

There’s a tutorial at

http://www.yiiframework.com/wiki/123/multiple-database-support-in-yii/

on how to use multiple databases with Yii.

Thanks BlkRaven .

i solved using this.





$dataProvidersphinx->db = $connection;




$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,


                ),


            ));