When I try to connect to my database, everything is ok, but when I try to use the query() command to execute a SQL statement I get this error:
The connection was reset
The connection to the server was reset while the page was
The page doesn't load.
$sql = <<<SQL
SELECT
1
FROM
dual
SQL;
$oci=Yii::app()->db;
$command = $oci->createCommand($sql);
$dataReader = $command->query();
I'm trying to do this in the index.php page, if I comment the last line, the page load successfully.
I tested the connection with echo isset(Yii::app()->db);
and I got 1.
I'm using oci8Pdo.OciDbConnection
class.
EDIT:
print_r($command) result:
CDbCommand Object ( [params] => Array ( ) [_connection:private] => OciDbConnection Object
( [pdoClass] => Oci8PDO [connectionString] => oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=********)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=********)));
[username] => ***** [password] => ******* [schemaCachingDuration] => 0
[schemaCachingExclude] => Array ( ) [schemaCacheID] => cache
[queryCachingDuration] => 0 [queryCachingDependency] => [queryCachingCount] => 0
[queryCacheID] => cache [autoConnect] => 1 [charset] => [emulatePrepare] =>
[enableParamLogging] => 1 [enableProfiling] => 1 [tablePrefix] => [initSQLs] =>
[driverMap] => Array ( [cubrid] => CCubridSchema [pgsql] => CPgsqlSchema
[mysqli] => CMysqlSchema [mysql] => CMysqlSchema [sqlite] => CSqliteSchema
[sqlite2] => CSqliteSchema [mssql] => CMssqlSchema [dblib] => CMssqlSchema
[sqlsrv] => CMssqlSchema [oci] => COciSchema ) [_driverName:private] => oci
[_attributes:private] => Array ( ) [_active:private] => 1 [_pdo:private] => Oci8PDO Object ( [_dbh:protected] => Resource id #51 [_options:protected] => Array ( [3] => 2 ) [_isTransaction:protected] => ) [_transaction:private] =>
[_schema:private] => [behaviors] => Array ( ) [_initialized:private] => 1
[_e:private] => [_m:private] => ) [_text:private] => SELECT 1 FROM dual
[_statement:private] => [_paramLog:private] => Array ( ) [_query:private] =>
[_fetchMode:private] => Array ( [0] => 2 ) [_e:private] => [_m:private] => )
EDIT2:
'db1'=>array(
'class'=>'ext.oci8Pdo.OciDbConnection',
'connectionString' => 'oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=**********)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=*******)));',
'username' => '***',
'password' => '****',
'emulatePrepare' => true,
/*
* enableProfiling and enableParamLogging are working like normal; Default is false.
*/
'enableProfiling' => true,
'enableParamLogging' => true,
),
well, apparently the oci8Pdo.OciDbConnection doesn't work in PHP 5.1 so I used CDbConnection with the right charset and it worked well.
You are using Yii::app()->db but your configuration file seems to be using "db1". Can you check it? This problem does not seem to be related to Yii, but simply an inability to connect to the right database system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With