I'm trying to use Zend_Db_Table with PDO_OCI driver but when I try to use SELECT I get his exception:
Message: SQLSTATE[HY000]: General error: 942 OCIStmtExecute: ORA-00942: table or view does not exist (/var/tmp/portage/dev-lang/php-7.1.4/work/sapis-build/apache2/ext/pdo_oci/oci_statement.c:159), query was: SELECT "all_tables"."table_name" FROM "all_tables"
This is my code:
class Application_Model_Tables extends Coret_Db_Table_Abstract
{
protected $_name = 'all_tables';
public function getAll()
{
$select = $this->_db->select()
->from($this->_name, 'table_name');
return $this->selectAll($select);
}
}
and this is code that works:
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$sql = 'SELECT table_name FROM all_tables';
$stmt = $db->query($sql);
return $stmt->fetchAll();
So it is clear that there is problem with double quotes added to table name. Is this some PDO_OCI bug or am I doing something wrong?
EDIT:
I know what double quotes does because it works the same in PostgreSQL and I work with PostgreSQL for a long time. Problem was that I didn't know that "all_tables" is not the real name as suggested in this question. The real name for this table is ALL_TABLES and real name for the column is TABLE_NAME. So the correct answer is that I had wrong table and column names and this is not related to the suggested duplicate because answers from it would not help me at all.