function countResultset($schStr = '', $schField = -1, $schArr = false) { if ($this->flg_select == 'true') { // check whether the flg_select is 'True' $arrayFieldList = $this->arr_select; //assign the sql_format->arr_select instance variable to arrayFieldList $countArrSize = count($arrayFieldList); // check the array size $SQL1 = 'SELECT count(*) FROM ' . strtolower($this->table_name); //Tail of the SQL statement if ($schField != -1) { $SQL1 = $SQL1 . ' WHERE '; if ($schArr) { for ($i = 0; $i < count($schField); $i++) { if ($schField[$i] != -1) { $SQL1 = $SQL1 . $arrayFieldList[$schField[$i]] . ' LIKE \'%' . trim(mysql_real_escape_string($schStr[$i])) . '%\' AND '; } } $SQL1 = substr($SQL1, 0, -1 - 4); } else { $SQL1 = $SQL1 . $arrayFieldList[$schField] . ' LIKE \'%' . trim(mysql_real_escape_string($schStr)) . '%\''; } } //$exception_handler = new ExceptionHandler(); //$exception_handler->logW($SQL1); return $SQL1; //returning the SQL1 which has the SQL Query } else { $exception_handler = new ExceptionHandler(); $exception_handler->dbexInvalidSQL(); echo "ERROR"; // put Exception Handling exit; } }
/** * This method will execute an SQL statement using mysql_query() function * @param String $sql SQL statement to be executed * @return ResultResource If the statement executed success, boolean false in an error */ public function sqlQuery($sql) { if (isset($this->conn) && $sql != '') { $this->result = mysql_query($sql); if ($this->result) { return $this->result; } /* * Return false if duplicate key is entered * TODO: Throw an exception here, and chanage code to catch it on model level */ if (mysql_errno() == 1062) { return false; } $exception_handler = new ExceptionHandler(); $exception_handler->dbexInvalidSQL($sql); return false; } else { $exception_handler = new ExceptionHandler(); $exception_handler->dbexNoQueryFound($sql); return false; } }
function sqlQuery($sql) { if (isset($this->conn) && $sql != '') { $this->result = mysql_query($sql); if ($this->result) { return $this->result; } if (mysql_errno() == 1062) { return false; } $exception_handler = new ExceptionHandler(); $exception_handler->dbexInvalidSQL($sql); return false; } else { $exception_handler = new ExceptionHandler(); $exception_handler->dbexNoQueryFound($sql); return false; } }