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,
),
query()
will give you only the text of your query, you have to usequeryAll()
function$oci=Yii::app()->db;
is working... I can var_dump it if you want.