function get_table($paged = 0) { /* Execute a prepared statement by passing an array of values */ $dbh = new PDO('mysql:dbname=' . AppConfig::gacv("AC_db") . ';host=' . AppConfig::gacv("AC_server"), AppConfig::gacv("AC_user"), AppConfig::gacv("AC_pass")); $sql = sprintf("select * from %s WHERE " . $this->lookup_tbl_id_col . " = :lookup_tbl_id_col OR 1 = :lookup_not_set order by %s", $this->tbl_name, $this->lookup_value_col); if ($paged) { $sql .= MyEDB_Pager::get_sql_limit_clause(); } $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY)); // //$sth->execute(array(':lookup_tbl_id_col' => ($_REQUEST[$this->lookup_tbl_id_col])? $_REQUEST[$this->lookup_tbl_id_col] : $this->lookup_tbl_id_col)); $sth->bindParam(':lookup_tbl_id_col', $lookup_tbl_id_col); $sth->bindParam(':lookup_not_set', $lookup_not_set); $lookup_tbl_id_col = $_REQUEST[$this->lookup_tbl_id_col]; $lookup_not_set = $_REQUEST[$this->lookup_tbl_id_col] ? 0 : 1; $sth->execute(); $res = $sth->fetchAll(PDO::FETCH_BOTH); //echo $sql.$this->lookup_tbl_id_col;// $table_hash = array(); //print_r($res); foreach ($res as $ar) { //echo $sql."-".$lookup_tbl_id_col." ".$lookup_not_set; $table_hash[$ar[0]] = array($ar[1], "lookup_table_id" => $ar[$this->lookup_tbl_id_col], "disabled" => $ar['disabled']); } return $table_hash; }
function delete_search_keys() { $dbh = new PDO('mysql:dbname=' . AppConfig::gacv("AC_db") . ';host=' . AppConfig::gacv("AC_server"), AppConfig::gacv("AC_user"), AppConfig::gacv("AC_pass")); $memcache_obj = memcache_pconnect('localhost', 11211); $sql = sprintf("select search_key from %s ", "memcache_search_keys"); $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY)); // $sth->execute(); $res = $sth->fetchAll(PDO::FETCH_BOTH); //echo $sql.$this->lookup_tbl_id_col;// foreach ($res as $ar) { memcache_delete($memcache_obj, $ar["search_key"], 0); } /* Delete all rows from the FRUIT table */ $count = $dbh->exec("DELETE FROM memcache_search_keys"); }
function update_medb_order_res_field_name_value($res_field_name, $new_value) { if (1 == get_magic_quotes_runtime() || 1 == get_magic_quotes_gpc()){ $new_value = stripslashes($new_value); //PDO does the escaping } $new_value = trim($new_value); //$new_value = htmlspecialchars($new_value,ENT_NOQUOTES); //echo htmlentities($new_value)."-[-"; die(); //$new_value = htmlentities($new_value, ENT_QUOTES); $dbh = new PDO('mysql:dbname='.AppConfig::gacv("AC_db").';host='.AppConfig::gacv("AC_server") ,AppConfig::gacv("AC_user"),AppConfig::gacv("AC_pass")); $sql = sprintf("select details_xml from medb_order WHERE order_id = :pdo_order_id "); $sth = $dbh->prepare($sql ,array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY));// //$sth->execute(array(':lookup_tbl_id_col' => ($_REQUEST[$this->lookup_tbl_id_col])? $_REQUEST[$this->lookup_tbl_id_col] : $this->lookup_tbl_id_col)); $sth->bindParam(':pdo_order_id',$this->order_id, PDO::PARAM_INT); // $sth->bindParam(':lookup_not_set',$lookup_not_set); // $lookup_tbl_id_col = $_REQUEST[$this->lookup_tbl_id_col] ; // $lookup_not_set = ($_REQUEST[$this->lookup_tbl_id_col])? 0 : 1; $sth->execute(); $details_xml = $sth->fetchColumn(); $xml = simplexml_load_string($details_xml); $result = $xml->xpath("/travel_res_info/travel_res_submitted_fields/travel_res_submit_field [@res_field_name='" . $res_field_name . "']" ); $result[0]->res_field_value=$new_value; $new_details_xml = $xml->asXML(); //echo "yoohoo".htmlentities($xml->asXML()); die; $sql = sprintf("update medb_order set details_xml = :new_details_xml WHERE order_id = :pdo_order_id "); $sth = $dbh->prepare($sql ,array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY));// //$sth->execute(array(':lookup_tbl_id_col' => ($_REQUEST[$this->lookup_tbl_id_col])? $_REQUEST[$this->lookup_tbl_id_col] : $this->lookup_tbl_id_col)); $sth->bindParam(':pdo_order_id',$this->order_id, PDO::PARAM_INT); $sth->bindParam(':new_details_xml',$new_details_xml); // $lookup_tbl_id_col = $_REQUEST[$this->lookup_tbl_id_col] ; // $lookup_not_set = ($_REQUEST[$this->lookup_tbl_id_col])? 0 : 1; $sth->execute(); return $new_value; }
function get_all_eids_by_type_category($type_category, $type_id) { /* $sql = "select distinct eid from view_varchar_prop_to_e_p_to_e natural join type where type_category = 'product' "; $eids = array(); $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $eids[] = $row['eid']; } return $eids; */ $dbh = new PDO('mysql:dbname=' . AppConfig::gacv("AC_db") . ';host=' . AppConfig::gacv("AC_server"), AppConfig::gacv("AC_user"), AppConfig::gacv("AC_pass")); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $all_types = 0; if ($type_id > 0) { $sql_type_id = $type_id; //echo "I'm here"; } else { $sql_type_id = ""; $all_types = 1; } $thisclass = get_class($this); $sql = sprintf("select distinct eid from {$thisclass} natural join type WHERE type_category = :the_type_category \n\t\t\t\tand (type_id = :sql_type_id or 1 = :all_types)"); //echo $sql; $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY)); // //$sth->execute(array(':lookup_tbl_id_col' => ($_REQUEST[$this->lookup_tbl_id_col])? $_REQUEST[$this->lookup_tbl_id_col] : $this->lookup_tbl_id_col)); $sth->bindParam(':the_type_category', $type_category); $sth->bindParam(':sql_type_id', $sql_type_id); $sth->bindParam(':all_types', $all_types, PDO::PARAM_INT); $sth->execute(); $res = $sth->fetchAll(PDO::FETCH_BOTH); //echo $sql.$this->lookup_tbl_id_col;// $eids = array(); // print_r($res); foreach ($res as $ar) { $eids[] = $ar['eid']; } return $eids; }
static function getpdo() { $dbh = new PDO('mysql:dbname='.AppConfig::gacv("AC_db").';host='.AppConfig::gacv("AC_server"),AppConfig::gacv("AC_user"),AppConfig::gacv("AC_pass")); return $dbh; }