Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Query{
- private $queryError;
- public function __construct(){
- $this->database = $GLOBALS['database'];
- }
- public function preparedQuery($query, $array = array()){
- try{
- $preparedQuery = $this->database->prepare($query);
- if($preparedQuery->execute($array)){
- return $preparedQuery;
- } else{
- return false;
- }
- } catch(Exception $e){
- $this->queryError = $e;
- return false;
- }
- }
- public function rowQuery($query, $array){
- try{
- $rowQuery = $this->database->prepare($query);
- if($rowQuery->execute($array)){
- $result = $rowQuery->fetchAll(PDO::FETCH_ASSOC);
- if(empty($result)){ // Needed to make sure false isnt returned for an empty array
- return array();
- } else{
- return $result;
- }
- }
- } catch(Exception $e){
- $this->queryError = $e;
- return false;
- }
- }
- }
- class Database{
- public function __construct(){
- $this->database = $GLOBALS['database'];
- }
- public function preparedQuery($query, $array = array()){
- try{
- $preparedQuery = $this->database->prepare($query);
- if($preparedQuery->execute($array)){
- return $preparedQuery;
- } else{
- return false;
- }
- } catch(Exception $e){
- Reply::error(["detail"=>"Something went horribly wrong. Please tell the sys admin to check the error log.".$e]);
- return false;
- }
- }
- public function rowQuery($query, $array){
- try{
- $rowQuery = $this->database->prepare($query);
- if($rowQuery->execute($array)){
- $result = $rowQuery->fetchAll(PDO::FETCH_ASSOC);
- if(empty($result)){ // Needed to make sure false isnt returned for an empty array
- return array();
- } else{
- return $result;
- }
- }
- } catch(Exception $e){
- Reply::error(["detail"=>"Something went horribly wrong. Please tell the sys admin to check the error log.".$e]);
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement