I am trying to use Yii active record with Oracle database but it seems Active record lacks support to Oracle databases the very first problem is quoting the table names. Consider this model
<?php
namespace app\models;
use yii\db\ActiveRecord;
class Tblleaves extends ActiveRecord
{
public static function tableName()
{
return 'tblleaves';
}
}
When I try to fetch all the records in my action with
$leaves = Tblleaves::find()->all();
It raises the exception with message 'table or view does not exist (/tmp/pear/download/PDO_OCI-1.0/oci_statement.c:142) The SQL being executed was: SELECT * FROM "tblleaves"'
If I query leaves like this
$connection = new \yii\db\Connection([
'dsn' => 'oci:dbname=//10.0.0.200:1521/orcl',
'username' => 'JISPBILCORBILLINGPRD501',
'password' => 'JISPBILCORBILLINGPRD501',
]);
$connection->open();
$command = $connection->createCommand('SELECT * FROM tblleaves');
$posts = $command->queryAll();
echo '<pre>'; print_r($posts); exit;
It works prefecly fine. I later commented the line of QueryBuilder
$tables = $this->quoteTableNames($tables, $params);
It also worked fine, but then ActiveRecord was not able to get the scheme of table so $leave->property was giving an error of undefined property. What is going on with active record