9

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,
),
Marc
  • 3,683
  • 8
  • 34
  • 48
Fabio Cardoso
  • 1,181
  • 1
  • 14
  • 37

2 Answers2

3

well, apparently the oci8Pdo.OciDbConnection doesn't work in PHP 5.1 so I used CDbConnection with the right charset and it worked well.

Fabio Cardoso
  • 1,181
  • 1
  • 14
  • 37
  • 1
    You're using PHP 5.1?! The last release was 9 years ago and there have been many, many security fixes since then. Your server must be utterly unsecure. Please do yourself (as a developer) and the internet (by not running vulnerable out-of-date software) a favour and update to the latest PHP! – timclutton Apr 28 '15 at 08:02
  • It's an ethernet based app for a company. Update the php to the latest version will cost some hours to modify the atual php app. But I agree with you and I appreciate your concern. – Fabio Cardoso Apr 28 '15 at 12:03
1

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.

rodrigovr
  • 454
  • 2
  • 7