We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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


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() {
        $this->_db = new Phalcon\Db\Adapter\Pdo\Oracle($this->_config);
        if (!$this->_db) {
            throw new Phalcon\Exception("Unable To Connect To Oracle Database");

    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);

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

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

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

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

            return true;
            return false;

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

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