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.