diff --git a/database/class-enp_quiz_db.php b/database/class-enp_quiz_db.php index c2ea0fa..dbdb07a 100644 --- a/database/class-enp_quiz_db.php +++ b/database/class-enp_quiz_db.php @@ -12,11 +12,12 @@ class enp_quiz_Db extends PDO { - public function __construct() { + public function __construct() + { // check if a connection already exists try { // config file for connection info and necessary variables - include($_SERVER["DOCUMENT_ROOT"].'/enp-quiz-database-config.php'); + include($_SERVER["DOCUMENT_ROOT"] . '/enp-quiz-database-config.php'); // Table names for dynamic reference $this->quiz_table = $enp_quiz_table_quiz; $this->quiz_option_table = $enp_quiz_table_quiz_option; @@ -40,28 +41,35 @@ public function __construct() { PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); // create the new connection - parent::__construct('mysql:host='.$enp_db_host.';dbname='.$enp_db_name, - $enp_db_user, - $enp_db_password, - $options); + parent::__construct( + 'mysql:host=' . $enp_db_host . ';dbname=' . $enp_db_name, + // for windows users possible fix for PDO error, change 'mysql:host=' line above to: + // 'sqlsrv:Server=' . $enp_db_host . ';Database=' . $enp_db_name, + $enp_db_user, + $enp_db_password, + $options + ); } catch (Exception $e) { $this->errors = $e->getMessage(); } } - public function query($sql, $params = null) { + public function runQuery($sql, $params = null) + { $stmt = $this->prepare($sql); $stmt->execute($params); return $stmt; } - public function fetchOne($sql, $params = []) { - $stmt = $this->query($sql, $params); + public function fetchOne($sql, $params = []) + { + $stmt = $this->runQuery($sql, $params); return $stmt->fetch(PDO::FETCH_ASSOC); } - public function fetchAll($sql, $params = []) { - $stmt = $this->query($sql, $params); + public function fetchAll($sql, $params = []) + { + $stmt = $this->runQuery($sql, $params); return $stmt->fetchAll(PDO::FETCH_ASSOC); } @@ -73,14 +81,7 @@ public function getQuizzes($where = []) { $params = $this->buildParams($where); - $sql = "SELECT * from ".$this->quiz_table." WHERE quiz_is_deleted = 0"; - - if($where) { - $sql .= $this->buildWhere($params, true); - } - - return $this->fetchAll($sql, $params); - } + $sql = "SELECT * from " . $this->quiz_table . " WHERE quiz_is_deleted = 0"; if ($where) { $sql .= $this->buildWhere($params, true); @@ -97,15 +98,15 @@ public function getDomains($where = []) { $params = $this->buildParams($where); - $sql = "SELECT DISTINCT(SUBSTRING_INDEX((SUBSTRING_INDEX((SUBSTRING_INDEX(embed_site_url, '://', -1)), '/', 1)), '.', -2)) as domain from ".$this->embed_site_table; - - if($where) { + $sql = "SELECT DISTINCT(SUBSTRING_INDEX((SUBSTRING_INDEX((SUBSTRING_INDEX(embed_site_url, '://', -1)), '/', 1)), '.', -2)) as domain from " . $this->embed_site_table; + + if ($where) { $sql .= $this->buildWhere($params, true); } - + return $this->fetchAll($sql, $params); } - + /* * Get Sites * @@ -114,14 +115,7 @@ public function getSites($where = []) { $params = $this->buildParams($where); - $sql = "SELECT * from ".$this->embed_site_table; - - if($where) { - $sql .= $this->buildWhere($params, true); - } - - return $this->fetchAll($sql, $params); - } + $sql = "SELECT * from " . $this->embed_site_table; if ($where) { $sql .= $this->buildWhere($params, true); @@ -138,14 +132,7 @@ public function getEmbeds($where = []) { $params = $this->buildParams($where); - $sql = "SELECT * from ".$this->embed_quiz_table; - - if($where) { - $sql .= $this->buildWhere($params, true); - } - - return $this->fetchAll($sql, $params); - } + $sql = "SELECT * from " . $this->embed_quiz_table; if ($where) { $sql .= $this->buildWhere($params, true); @@ -179,30 +166,10 @@ public function getSliderQuestionsTotal() return (int) $this->fetchOne($sql)['COUNT(*)']; } - } - public function buildWhere($params, $where = true) { - $sql = ''; - if($where === true) { - $sql = ' WHERE '; - } - if(!empty($params)) { - $i = 1; - foreach($params as $key => $val) { - if(is_array($val)) { - // for things like 'date > :date' - $sql .= $val['key'].' '.$val['operator'].' '.$val['val']; - } else { - $sql .= $key.' = '.$val; - } - if($i !== count($params)) { - // not the last one, so add an AND statement - $where .= " AND "; - $i++; - } - } - } - return $sql; - } + public function getUniqueUsersTotal() + { + $sql = "SELECT COUNT(DISTINCT user_id) as users + FROM " . $this->response_quiz_table; return (int) $this->fetchOne($sql)['users']; } diff --git a/database/class-enp_quiz_save_ab_test.php b/database/class-enp_quiz_save_ab_test.php index 828f8ef..e557db9 100644 --- a/database/class-enp_quiz_save_ab_test.php +++ b/database/class-enp_quiz_save_ab_test.php @@ -232,7 +232,7 @@ private function insert_ab_test($ab_test) { :ab_test_updated_at )"; // insert the quiz into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $this->response['action'] = 'insert'; // success! @@ -277,7 +277,7 @@ private function delete_ab_test($ab_test) { AND quiz_id_a = :quiz_id_a AND quiz_id_b = :quiz_id_b"; // insert the quiz into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // start the response $this->response['action'] = 'update'; diff --git a/database/class-enp_quiz_save_embed_quiz.php b/database/class-enp_quiz_save_embed_quiz.php index e05e98b..7cff957 100644 --- a/database/class-enp_quiz_save_embed_quiz.php +++ b/database/class-enp_quiz_save_embed_quiz.php @@ -195,7 +195,7 @@ protected function insert_embed_quiz($embed_quiz) { :embed_quiz_updated_at )"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -245,7 +245,7 @@ protected function update_embed_quiz_loads($embed_quiz) { embed_quiz_updated_at = :embed_quiz_updated_at WHERE embed_quiz_id = :embed_quiz_id"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_embed_site.php b/database/class-enp_quiz_save_embed_site.php index 7e465b9..e0213a0 100644 --- a/database/class-enp_quiz_save_embed_site.php +++ b/database/class-enp_quiz_save_embed_site.php @@ -150,7 +150,7 @@ protected function insert_embed_site($embed_site) { :embed_site_updated_at )"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_mc_option.php b/database/class-enp_quiz_save_mc_option.php index cf6ecd8..7bc257b 100644 --- a/database/class-enp_quiz_save_mc_option.php +++ b/database/class-enp_quiz_save_mc_option.php @@ -215,7 +215,7 @@ protected function insert_mc_option() { :mc_option_responses )"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -263,7 +263,7 @@ protected function update_mc_option() { WHERE mc_option_id = :mc_option_id"; // update the mc_option in the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_question.php b/database/class-enp_quiz_save_question.php index 8e5045b..246d0a8 100644 --- a/database/class-enp_quiz_save_question.php +++ b/database/class-enp_quiz_save_question.php @@ -412,7 +412,7 @@ protected function insert_question() { :question_time_spent_average )'; // insert the question into the database - $stmt = $pdo->query( $sql, $params ); + $stmt = $pdo->runQuery( $sql, $params ); // success! if($stmt !== false ) { @@ -475,7 +475,7 @@ protected function update_question() { WHERE question_id = :question_id'; // update the question in the database - $stmt = $pdo->query( $sql, $params ); + $stmt = $pdo->runQuery( $sql, $params ); // success! if($stmt !== false ) { diff --git a/database/class-enp_quiz_save_quiz.php b/database/class-enp_quiz_save_quiz.php index c2a2a59..50e2ff5 100644 --- a/database/class-enp_quiz_save_quiz.php +++ b/database/class-enp_quiz_save_quiz.php @@ -549,7 +549,7 @@ protected function insert_quiz() { :quiz_is_deleted )"; // insert the quiz into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -588,7 +588,7 @@ protected function update_quiz() { AND quiz_owner = :quiz_owner "; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -675,7 +675,7 @@ protected function pdo_publish_quiz() { WHERE quiz_id = :quiz_id AND quiz_owner = :quiz_owner"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -1101,7 +1101,7 @@ protected function get_all_quiz_ab_tests($quiz_id) { $sql = "SELECT ab_test_id from ".$pdo->ab_test_table." WHERE (quiz_id_a = :quiz_id OR quiz_id_b = :quiz_id) AND ab_test_is_deleted = 0"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $ab_test_row = $stmt->fetchAll(PDO::FETCH_COLUMN); // return the found quiz row return $ab_test_row; diff --git a/database/class-enp_quiz_save_quiz_option.php b/database/class-enp_quiz_save_quiz_option.php index 007ca72..67c7c96 100644 --- a/database/class-enp_quiz_save_quiz_option.php +++ b/database/class-enp_quiz_save_quiz_option.php @@ -54,7 +54,7 @@ protected function select_quiz_option($quiz_option) { $sql = "SELECT quiz_option_id from ".$pdo->quiz_option_table." WHERE quiz_id = :quiz_id AND quiz_option_name = :quiz_option_name" ; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $option_row = $stmt->fetch(); return $option_row; } @@ -80,7 +80,7 @@ protected function insert_quiz_option($quiz_option) { :quiz_option_value )"; // insert the quiz into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -116,7 +116,7 @@ protected function update_quiz_option($quiz_option, $quiz_option_id) { AND quiz_option_name = :quiz_option_name "; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_quiz_take_response_ab_test.php b/database/class-enp_quiz_save_quiz_take_response_ab_test.php index e24baab..eadd1a3 100644 --- a/database/class-enp_quiz_save_quiz_take_response_ab_test.php +++ b/database/class-enp_quiz_save_quiz_take_response_ab_test.php @@ -59,7 +59,7 @@ private function insert_response_ab_test($ab_test_id, $response_quiz_id) { :ab_test_id )"; // update the question view the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_quiz_take_response_mc.php b/database/class-enp_quiz_save_quiz_take_response_mc.php index bd15267..f8617a7 100644 --- a/database/class-enp_quiz_save_quiz_take_response_mc.php +++ b/database/class-enp_quiz_save_quiz_take_response_mc.php @@ -46,7 +46,7 @@ protected function insert_response_mc($response) { :mc_option_id )"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -87,7 +87,7 @@ protected function increase_mc_option_responses($mc_option_id) { SET mc_option_responses = mc_option_responses + 1 WHERE mc_option_id = :mc_option_id"; // update the question view the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_quiz_take_response_question.php b/database/class-enp_quiz_save_quiz_take_response_question.php index 669156a..90440cb 100644 --- a/database/class-enp_quiz_save_quiz_take_response_question.php +++ b/database/class-enp_quiz_save_quiz_take_response_question.php @@ -176,7 +176,7 @@ public function insert_response_question($response) { :response_question_updated_at )"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -235,7 +235,7 @@ public function update_response_question($response) { response_question_updated_at = :response_question_updated_at WHERE response_question_id = :response_question_id"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -310,7 +310,7 @@ protected function update_question_response_data($response) { question_responses_incorrect_percentage = question_responses_incorrect/question_responses WHERE question_id = :question_id"; // update the question view the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -340,7 +340,7 @@ protected function get_response_question_id($response) { $sql = "SELECT response_question_id from ".$pdo->response_question_table." WHERE response_quiz_id = :response_quiz_id AND question_id = :question_id"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $result = $stmt->fetch(); return $result['response_question_id']; } diff --git a/database/class-enp_quiz_save_quiz_take_response_quiz.php b/database/class-enp_quiz_save_quiz_take_response_quiz.php index 69a2ec9..c6935dd 100644 --- a/database/class-enp_quiz_save_quiz_take_response_quiz.php +++ b/database/class-enp_quiz_save_quiz_take_response_quiz.php @@ -59,7 +59,7 @@ public function insert_response_quiz($response) { :response_quiz_viewed_at )"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -105,7 +105,7 @@ public function update_response_quiz_started($response) { WHERE response_quiz_id = :response_quiz_id AND quiz_id = :quiz_id"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -151,7 +151,7 @@ protected function update_response_quiz_completed($response) { WHERE response_quiz_id = :response_quiz_id AND quiz_id = :quiz_id"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -196,7 +196,7 @@ public function update_response_quiz_restarted($response) { WHERE response_quiz_id = :response_quiz_id AND quiz_id = :quiz_id"; // insert the mc_option into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_quiz_take_response_slider.php b/database/class-enp_quiz_save_quiz_take_response_slider.php index 01796da..14658a0 100644 --- a/database/class-enp_quiz_save_quiz_take_response_slider.php +++ b/database/class-enp_quiz_save_quiz_take_response_slider.php @@ -49,7 +49,7 @@ protected function insert_response_slider($response) { :response_slider )"; // insert the slider into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/database/class-enp_quiz_save_slider.php b/database/class-enp_quiz_save_slider.php index 843e8d5..452b82f 100644 --- a/database/class-enp_quiz_save_slider.php +++ b/database/class-enp_quiz_save_slider.php @@ -212,7 +212,7 @@ protected function insert_slider() { :slider_suffix )"; // insert the slider into the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { @@ -267,7 +267,7 @@ protected function update_slider() { WHERE slider_id = :slider_id"; // update the slider in the database - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); // success! if($stmt !== false) { diff --git a/includes/class-enp_embed-domain.php b/includes/class-enp_embed-domain.php index 6b221a5..83832e5 100644 --- a/includes/class-enp_embed-domain.php +++ b/includes/class-enp_embed-domain.php @@ -58,7 +58,7 @@ public function select_embed_site_ids_by_domain($domain) { $sql = "SELECT embed_site_id, SUBSTRING_INDEX((SUBSTRING_INDEX((SUBSTRING_INDEX(embed_site_url, '://', -1)), '/', 1)), '.', -2) as domain from ".$pdo->embed_site_table." WHERE embed_site_is_dev=0 HAVING domain = :domain"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_domain_rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // return the found domain row ids diff --git a/includes/class-enp_embed-quiz.php b/includes/class-enp_embed-quiz.php index ddfbe59..caf6d7b 100644 --- a/includes/class-enp_embed-quiz.php +++ b/includes/class-enp_embed-quiz.php @@ -71,7 +71,7 @@ public function select_embed_quiz_by_id($embed_quiz_id) { $sql = "SELECT * from ".$pdo->embed_quiz_table." WHERE embed_quiz_id = :embed_quiz_id"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_quiz_row = $stmt->fetch(); // return the found site row return $embed_quiz_row; @@ -94,7 +94,7 @@ public function select_embed_quiz_by_url($query) { $sql = "SELECT * from ".$pdo->embed_quiz_table." WHERE embed_quiz_url = :embed_quiz_url AND quiz_id = :quiz_id"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_quiz_row = $stmt->fetch(); // return the found site row return $embed_quiz_row; diff --git a/includes/class-enp_embed-site-bridge.php b/includes/class-enp_embed-site-bridge.php index fff4f61..a0fd53a 100644 --- a/includes/class-enp_embed-site-bridge.php +++ b/includes/class-enp_embed-site-bridge.php @@ -75,7 +75,7 @@ protected function select_embed_site_bridge_by_site($site_id) { // there *should* only be one since embed_syte_type is a unique column $sql = "SELECT * from ".$pdo->embed_site_br_site_type_table." WHERE embed_site_id = :site_id"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_bridge_rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // return the found rows return $embed_bridge_rows; @@ -97,7 +97,7 @@ protected function select_embed_site_bridge_by_type($type_id) { // there *should* only be one since embed_syte_type is a unique column $sql = "SELECT * from ".$pdo->embed_site_br_site_type_table." WHERE embed_site_type_id = :type_id"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_bridge_rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // return the found rows return $embed_bridge_rows; diff --git a/includes/class-enp_embed-site-type.php b/includes/class-enp_embed-site-type.php index b880712..1bf2dbb 100644 --- a/includes/class-enp_embed-site-type.php +++ b/includes/class-enp_embed-site-type.php @@ -64,7 +64,7 @@ protected function select_embed_site_type_by_slug($embed_site_type_slug) { // there *should* only be one since embed_syte_type is a unique column $sql = "SELECT * from ".$pdo->embed_site_type_table." WHERE embed_site_type_slug = :embed_site_type_slug"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_site_row = $stmt->fetch(); // return the found row return $embed_site_row; @@ -88,7 +88,7 @@ protected function select_embed_site_type_by_id($embed_site_type_id) { $sql = "SELECT * from ".$pdo->embed_site_type_table." WHERE embed_site_type_id = :embed_site_type_id LIMIT 1"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_site_row = $stmt->fetch(); // return the found quiz row return $embed_site_row; diff --git a/includes/class-enp_embed-site.php b/includes/class-enp_embed-site.php index ebd52d0..4fbc6bb 100644 --- a/includes/class-enp_embed-site.php +++ b/includes/class-enp_embed-site.php @@ -62,7 +62,7 @@ public function select_embed_site_by_url($embed_site_url) { $sql = "SELECT * from ".$pdo->embed_site_table." WHERE embed_site_url = :embed_site_url"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_site_row = $stmt->fetch(); // return the found site row return $embed_site_row; @@ -89,7 +89,7 @@ public function select_embed_site_by_id($embed_site_id) { $sql = "SELECT * from ".$pdo->embed_site_table." WHERE embed_site_id = :embed_site_id"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_site_row = $stmt->fetch(); // return the found site row return $embed_site_row; @@ -110,7 +110,7 @@ public function select_embed_quizzes_by_site_id($site_id) { $sql = "SELECT embed_quiz_id from ".$pdo->embed_quiz_table." WHERE embed_site_id = :embed_site_id"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $embed_quiz_row = $stmt->fetchAll(PDO::FETCH_ASSOC); // return the found site row return $embed_quiz_row; diff --git a/includes/class-enp_quiz-ab_test.php b/includes/class-enp_quiz-ab_test.php index be0bb5f..172868c 100644 --- a/includes/class-enp_quiz-ab_test.php +++ b/includes/class-enp_quiz-ab_test.php @@ -52,7 +52,7 @@ public function select_ab_test_by_id($ab_test_id) { $sql = "SELECT * from ".$pdo->ab_test_table." WHERE ab_test_id = :ab_test_id AND ab_test_is_deleted = 0"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $ab_test_row = $stmt->fetch(); // return the found quiz row return $ab_test_row; diff --git a/includes/class-enp_quiz-mc_option_ab_test_result.php b/includes/class-enp_quiz-mc_option_ab_test_result.php index f95ee75..cdaef9a 100644 --- a/includes/class-enp_quiz-mc_option_ab_test_result.php +++ b/includes/class-enp_quiz-mc_option_ab_test_result.php @@ -38,7 +38,7 @@ public function select_ab_test_question_results($ab_test_id) { WHERE ab_response.ab_test_id = :ab_test_id AND mc_response.mc_option_id = :mc_option_id AND mc_response.response_mc_is_deleted = 0"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $results = $stmt->fetchColumn(); // return the found results return $results; diff --git a/includes/class-enp_quiz-question.php b/includes/class-enp_quiz-question.php index bd050ad..9791984 100644 --- a/includes/class-enp_quiz-question.php +++ b/includes/class-enp_quiz-question.php @@ -75,7 +75,7 @@ public function select_question_by_id( $question_id ) { $sql = 'SELECT * from ' . $pdo->question_table . ' WHERE question_id = :question_id AND question_is_deleted = 0'; - $stmt = $pdo->query( $sql, $params ); + $stmt = $pdo->runQuery( $sql, $params ); $question_row = $stmt->fetch(); // return the found question row return $question_row; @@ -276,7 +276,7 @@ protected function set_mc_options() { question_id = :question_id AND mc_option_is_deleted = 0 ORDER BY mc_option_order ASC'; - $stmt = $pdo->query( $sql, $params ); + $stmt = $pdo->runQuery( $sql, $params ); $mc_option_rows = $stmt->fetchAll( PDO::FETCH_ASSOC ); $mc_options = array(); @@ -312,7 +312,7 @@ protected function set_slider() { $sql = 'SELECT slider_id from ' . $pdo->question_slider_table . ' WHERE question_id = :question_id AND slider_is_deleted = 0'; - $stmt = $pdo->query( $sql, $params ); + $stmt = $pdo->runQuery( $sql, $params ); $slider_id = $stmt->fetch(); return $slider_id['slider_id']; } diff --git a/includes/class-enp_quiz-question_ab_test_result.php b/includes/class-enp_quiz-question_ab_test_result.php index 1091981..5e023bc 100644 --- a/includes/class-enp_quiz-question_ab_test_result.php +++ b/includes/class-enp_quiz-question_ab_test_result.php @@ -39,7 +39,7 @@ public function select_ab_test_question_results($question_id, $ab_test_id) { WHERE ab_response.ab_test_id = :ab_test_id AND question_response.question_id = :question_id AND question_response.response_question_is_deleted = 0"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); // return the found results diff --git a/includes/class-enp_quiz-quiz_ab_test_result.php b/includes/class-enp_quiz-quiz_ab_test_result.php index d4a7d8d..e25c249 100644 --- a/includes/class-enp_quiz-quiz_ab_test_result.php +++ b/includes/class-enp_quiz-quiz_ab_test_result.php @@ -45,7 +45,7 @@ public function select_ab_test_quiz_results($quiz_id, $ab_test_id) { WHERE ab_response.ab_test_id = :ab_test_id AND quiz_response.quiz_id = :quiz_id AND quiz_response.response_quiz_is_deleted = 0"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); // return the found results diff --git a/includes/class-enp_quiz-search_quizzes.php b/includes/class-enp_quiz-search_quizzes.php index 9e486e0..99d69d9 100644 --- a/includes/class-enp_quiz-search_quizzes.php +++ b/includes/class-enp_quiz-search_quizzes.php @@ -241,13 +241,13 @@ public function select_quizzes_one_user() { ORDER BY $this->order_by $this->order LIMIT $this->limit OFFSET $this->offset"; - $stmt = $pdo->query($sql); + $stmt = $pdo->runQuery($sql); $quiz_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); $total_sql = "SELECT COUNT(*) from $pdo->quiz_table WHERE quiz_is_deleted = $this->deleted $AND_sql"; - $total_stmt = $pdo->query($total_sql); + $total_stmt = $pdo->runQuery($total_sql); $this->total = $total_stmt->fetchColumn(); return $quiz_ids; @@ -296,7 +296,7 @@ public function search_include_quizzes_all_users_join() { ORDER BY quiz.$this->order_by $this->order LIMIT $this->limit OFFSET $this->offset"; - $stmt = $pdo->query($sql); + $stmt = $pdo->runQuery($sql); $quiz_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); // get the total found @@ -305,7 +305,7 @@ public function search_include_quizzes_all_users_join() { ON quiz.quiz_created_by = user.ID WHERE quiz.quiz_is_deleted = $this->deleted $user_sql"; - $total_stmt = $pdo->query($total_sql); + $total_stmt = $pdo->runQuery($total_sql); $this->total = $total_stmt->fetchColumn(); return $quiz_ids; @@ -342,7 +342,7 @@ public function search_include_quizzes_all_users() { WHERE quiz_is_deleted = $this->deleted $initial_AND_sql ORDER BY $this->order_by $this->order"; - $stmt = $pdo->query($sql); + $stmt = $pdo->runQuery($sql); $quiz_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); @@ -386,12 +386,12 @@ public function search_include_quizzes_all_users() { ORDER BY $this->order_by $this->order LIMIT $this->limit OFFSET $this->offset"; - $stmt = $pdo->query($sql); + $stmt = $pdo->runQuery($sql); $quiz_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); $total_sql = "SELECT COUNT(*) from $pdo->quiz_table WHERE quiz_is_deleted = $this->deleted $user_sql"; - $total_stmt = $pdo->query($total_sql); + $total_stmt = $pdo->runQuery($total_sql); $this->total = $total_stmt->fetchColumn(); return $quiz_ids; diff --git a/includes/class-enp_quiz-slider-ab_result.php b/includes/class-enp_quiz-slider-ab_result.php index 3841741..1fb5738 100644 --- a/includes/class-enp_quiz-slider-ab_result.php +++ b/includes/class-enp_quiz-slider-ab_result.php @@ -37,7 +37,7 @@ public function select_ab_test_slider_results($ab_test_id) { WHERE ab_response.ab_test_id = :ab_test_id AND slider_response.slider_id = :slider_id AND slider_response.response_slider_is_deleted = 0"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $results = $stmt->fetchAll(PDO::FETCH_COLUMN); // return the found results return $results; diff --git a/includes/class-enp_quiz-slider-result.php b/includes/class-enp_quiz-slider-result.php index d7e5358..5037323 100644 --- a/includes/class-enp_quiz-slider-result.php +++ b/includes/class-enp_quiz-slider-result.php @@ -42,7 +42,7 @@ public function select_slider_question_results($slider_id) { WHERE slider_id = :slider_id AND response_slider_is_deleted = 0 ORDER BY response_slider"; - $stmt = $pdo->query($sql, $params); + $stmt = $pdo->runQuery($sql, $params); $results = $stmt->fetchAll(PDO::FETCH_COLUMN); // return the found results return $results; diff --git a/upgrade.php b/upgrade.php index e6403f5..e675a43 100644 --- a/upgrade.php +++ b/upgrade.php @@ -64,7 +64,7 @@ public function resave_quizzes() { public function get_all_quiz_ids() { $pdo = new enp_quiz_Db(); $sql = "SELECT quiz_id from ".$pdo->quiz_table; - $stmt = $pdo->query($sql); + $stmt = $pdo->runQuery($sql); $quiz_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); return $quiz_ids; }