/** * @param \PDOStatement $stmt Statement to execute * * @return bool|array|object[] */ protected function _execStatement($stmt) { $className = $this->tableNameToClassName(); if (isset($className) && empty($this->_nonexistantClassCache[$className])) { try { if (!class_exists("\\App\\Models\\{$className}")) { throw new \Exception(); } $this->setClass("\\App\\Models\\{$className}"); } catch (\Exception $e) { $this->_nonexistantClassCache[$className] = true; } } $this->queryCount++; return parent::_execStatement($stmt); }
<?php $_ = array('TESTDB_CONNECTION_ERROR' => 0xfff, 'TABLEEXISTS_NOT_FALSE' => 0x100, 'TABLEEXISTS_NOT_TRUE' => 0x101, 'GET_QUERY_MISMATCH' => 0x200, 'GET_RETURNING_WRONG_DATA' => 0x201, 'GET_QUERY_LIMIT_MISMATCH' => 0x202, 'GET_QUERY_ARRAY_LIMIT_MISMATCH' => 0x203, 'GET_RETURN_MISSING_RESULT' => 0x204, 'GET_RETURN_TOO_MANY_RESULT' => 0x205, 'GET_RETURN_WRONG_RESULT_TYPE_STRING' => 0x206, 'GET_RETURN_WRONG_RESULT_TYPE_INT' => 0x207, 'INSERT_QUERY_MISMATCH' => 0x300, 'INSERT_RETURN_WRONG_DATA' => 0x301, 'INSERT_RETURN_WRONG_DATA_TYPE_INT' => 0x302, 'INSERT_RETURN_WRONG_DATA_TYPE_STRING' => 0x303, 'INSERT_DUPE_PRIMARY_KEY_WRONG_ERROR_MSG' => 0x304, 'GETONE_QUERY_MISMATCH' => 0x400, 'GETONE_RETURNING_WRONG_STRUCTURE' => 0x401, 'GETONE_RETURNING_WRONG_DATA' => 0x402, 'GETONE_QUERY_COLUMN_MISMATCH' => 0x403, 'GETONE_RETURNING_WRONG_DATA_TYPE_INT' => 0x402, 'GETONE_RETURNING_WRONG_DATA_TYPE_STRING' => 0x402, 'GETONE_RETURNING_COLUMN_WRONG_DATA' => 0x403, 'WHERE_QUERY_MISMATCH' => 0x500, 'WHERE_RETURNING_WRONG_DATA' => 0x501, 'WHERE_QUERY_STRING_MISMATCH' => 0x502, 'WHERE_QUERY_ARRAY_MISMATCH' => 0x503, 'WHERE_RETURNING_WRONG_DATA_TYPE_INT' => 0x504, 'WHERE_RETURNING_WRONG_DATA_TYPE_STRING' => 0x505, 'ORDERBY_QUERY_MISMATCH' => 0x600, 'ORDERBY_RETURNING_WRONG_DATA' => 0x601, 'ORDERBY_RETURNING_WRONG_DATA_TYPE_INT' => 0x602, 'ORDERBY_RETURNING_WRONG_DATA_TYPE_STRING' => 0x603, 'RAWQUERY_QUERY_MISMATCH' => 0x700, 'RAWQUERY_RETURNING_WRONG_DATA' => 0x701, 'COUNT_QUERY_MISMATCH' => 0x800, 'COUNT_RETURNING_WRONG_DATA_TYPE' => 0x801, 'COUNT_RETURNING_WRONG_DATA' => 0x802, 'HAS_RETURNING_WRONG_DATA_TYPE' => 0x900, 'HAS_RETURNING_WRONG_DATA' => 0x901, 'DELETE_WHERE_NOT_DELETING' => 0xa00, 'DELETE_WHERE_DELETING_WRONG_ROWS' => 0xa01, 'DELETE_NOT_DELETING' => 0xa02); function fail($exitkey) { global $_; if (!isset($_[$exitkey])) { throw new Exception("FAILURE: {$exitkey} (invalid exit code)"); } $RawExitCode = $_[$exitkey]; $ExitCode = '0x' . strtoupper(dechex($RawExitCode)); throw new Exception("FAILURE: {$exitkey} ({$ExitCode})\n"); } require "PostgresDb.php"; $Database = new PostgresDb('test', 'localhost', 'postgres', ''); function checkQuery($expect, $exitkey) { global $Database; if (empty($Database)) { return false; } $LastQuery = $Database->getLastQuery(); if ($expect !== $LastQuery) { echo "Mismatched query string:\n"; var_dump($LastQuery); fail($exitkey); } } // Check tableExists & rawQuery try { if ($Database->tableExists('users') !== false) {