Syntax error or access violation using PDO: SQLSTATE[42000]: Syntax error or access violation: 1142

Code

<?php
class IndexModel extends \TNB\Mvc\ModelBase {

    private $_db;
    private $_data; 

    private $_config = array(
        "dbname" => "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = myHost)(PORT = myPort)))(CONNECT_DATA=(SID=mySSID)))",
        "username" => "dbUser",
        "password" => "dbPass"
    ); 

     public function initialize() {
        parent::__construct();
        $this->_db = new Phalcon\Db\Adapter\Pdo\Oracle($this->_config);
        if (!$this->_db) {
            throw new Phalcon\Exception("Unable To Connect To Oracle Database");
        }
        $this->getData();
    }

    private function queryDatabase($sqlQuery) {
        // make sure we have a
        if (null == $this->_db) {
            throw new Exception("No Available Connections to Oracle");
        }
        // query the database
        $result = $this->_db->fetchAll($sqlQuery, Phalcon\Db::FETCH_ASSOC);
        return $result;
    }

    private function queryReturnData(){
        $sqlQuery = "SELECT * FROM APPS.MY_DATABASE";

        $returnData = array();

        $records = $this->db->query($sqlQuery);
        $records->setFetchMode(Phalcon\Db::FETCH_ASSOC);

        while ($record = $availableRecords->fetch()) {
            $retData[] = $record;
        }

        //$retData[] = $sqlQuery;
        return $returnData;
    }

    public function getIndexData(){
        return $this->_data;
    }

    private function getData()
    {
        $this->_data = $this->queryReturnData(null);

        if($this->_data){
            return true;
        }else{
            return false;
        }   
    }
}

I was working on a small project to display some database but ran into this error. Any help would be appreciated.



67.7k
edited Jul '16

my guess would be that you are using a reserved word. You masked the db and table names ( which is ok ) my guess is to check there )

list of reserved stuff https://dev.mysql.com/doc/refman/5.5/en/keywords.html oh you are using oracle, so no idea which words are reserved, never used it myself

lets hope i am lucky :D