public function indexAction() { $key = $this->getRequest()->get('kw'); $orderby = $this->getRequest()->get('od'); $page = $this->getRequest()->get('page', 1); // $router = \Yaf\Dispatcher::getInstance()->getRouter(); // $config = \Yaf\Application::app()->getConfig(); $search = new Search(); $search->setQ($key); $search->setPage($page); if (!empty($orderby)) { $search->setSortby($orderby); } $res = $search->query(); $pages = 1; $films = null; if ($res) { $pages = empty($res['pages']) ? 1 : $res['pages']; if (isset($res['matches'])) { foreach ($res['matches'] as $match) { $ids[] = $match['id']; } $conn = new MyPDO(); $films = $conn->table('film')->select('*')->where('id in (' . implode(',', $ids) . ')')->orderBy('order by find_in_set (id, \'' . implode(',', $ids) . '\')')->execute(); } } $this->_view->assign('films', $films); $this->_view->assign('kw', $key); $this->_view->assign('orderby', $orderby); $this->_view->assign('page', $page); $this->_view->assign('pages', $pages); }
public static function deleteItem($item_order) { $db = new MyPDO(); $row = $db->prepare('DELETE FROM playlist WHERE order_number = :item_order LIMIT 1'); $row->bindParam('item_order', $item_order, PDO::PARAM_INT); $row->execute(); $db = null; }
/** * Called by the constructor */ protected function prepare() { // since PDO can emulate prepared statement, prepare() do not always // communicate with the database, and therefore do not trigger automatic // reconnection. Instead we manually check if the connection is alive. if (!$this->dbh->ping()) { $this->dbh->autoreconnect(); } $this->pdo_statement = $this->dbh->__call('prepare', array($this->statement, $this->driver_options)); }
/** * Singleton instance * * @return Object */ public static function getInstance($dbHost, $dbUser, $dbPasswd, $dbName, $dbCharset) { if (self::$_instance === null) { self::$_instance = new self($dbHost, $dbUser, $dbPasswd, $dbName, $dbCharset); } return self::$_instance; }
public static function getInstance() { if (empty(self::$instance)) { self::$instance = new MyPDO(); } return self::$instance; }
public function __construct() { //调用父类的构造方法 parent::__construct(); //修改session机制 session_set_save_handler(array($this, 'sess_open'), array($this, 'sess_close'), array($this, 'sess_read'), array($this, 'sess_write'), array($this, 'sess_destroy'), array($this, 'sess_gc')); }
protected function connect($name) { if (array_key_exists('host', $this->_connections[$name]['connection_data'])) { $host = $this->_connections[$name]['connection_data']['host']; } else { $host = 'localhost'; } if (array_key_exists('port', $this->_connections[$name]['connection_data'])) { $port = $this->_connections[$name]['connection_data']['port']; } else { $port = self::DEFAULT_MYSQL_PORT; } if (array_key_exists('user', $this->_connections[$name]['connection_data'])) { $user = $this->_connections[$name]['connection_data']['user']; } else { $user = ''; } if (array_key_exists('password', $this->_connections[$name]['connection_data'])) { $password = $this->_connections[$name]['connection_data']['password']; } else { $password = ''; } if (array_key_exists('dbname', $this->_connections[$name]['connection_data'])) { $dbname = $this->_connections[$name]['connection_data']['dbname']; } else { $dbname = null; } $this->_connections[$name]['connected'] = true; try { $dsn = "mysql:host={$host}"; if ($port !== null) { $dsn .= ";port={$port}"; } if ($dbname !== null) { $dsn .= ";dbname={$dbname}"; } $dbh = new MyPDO($dsn, $user, $password, array()); } catch (PDOException $e) { throw new DB_Connection_Failure_Exception($name); } $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); $dbh->exec('SET CHARACTER SET utf8'); $this->_connections[$name]['pdo'] = $dbh; }
function search($svalue, $price, $level, $attr = "自主") { $db = MyPDO::getInstance('localhost', 'afei', '8823533', 'cars_db', 'utf8'); $prices = explode("-", $price); $price = $prices[0]; $priceb = isset($prices[1]) ? $prices[1] : "暂无"; $query = 'SELECT DISTINCT `name`,englishName,price,priceb,sourceId FROM(SELECT DISTINCT a.`name`, a.englishName,a.price,a.priceb,a.sourceId FROM `mediumgaugecarportfolio` a ,`mediumgaugecar` b WHERE a.sourceId=b.seriesId AND a.`name` LIKE \'%' . $svalue . '%\' AND b.valueName="级别" AND b.`value` LIKE \'%' . $level . 'SUV\' AND a.price BETWEEN ' . $price . ' AND ' . $priceb . ' UNION ALL SELECT DISTINCT a.`name`, a.englishName,a.price,a.priceb,a.sourceId FROM `mediumgaugecarportfolio` a ,`mediumgaugecar` b WHERE a.sourceId=b.seriesId AND a.`name` LIKE \'%' . $svalue . '%\' AND b.valueName="级别" AND b.`value` LIKE \'%' . $level . 'SUV\' AND a.priceb BETWEEN ' . $price . ' AND ' . $priceb . ')t ORDER BY price ASC'; $rs = $db->query($query); $db->destruct(); return $rs; }
/** * Get single instance of class * * @return MyPDO */ public static function getInstance() { if (is_null(self::$_instance)) { $dbConfig = (require_once __DIR__ . '/../dbconfig.php'); self::$_instance = new MyPDO($dbConfig); if (is_null(self::$_instance)) { self::$_instance = new MyPDO($dbConfig); } else { self::$_instance->exec("set names utf8"); } } return self::$_instance; }
/** * Save current Model * @param type $params */ public function save($params = null) { $instance = MyPDO::getInstance(); if (is_null($params)) { $params = $this->_data; } if (isset($params['id'])) { $id = $params['id']; unset($params['id']); $instance->updateTable($this->getTable(), $id, $params); } else { $instance->insert_table($this->getTable(), $params); } }
public function query($query) { //secured query with prepare and execute $timestart = microtime(true); $args = func_get_args(); array_shift($args); //first element is not an argument but the query itself, should removed if (is_array(@$args[0])) { $args = $args[0]; } if (MyPDO::$cache_activate && isset(MyPDO::$cache[$query . "::" . serialize($args)])) { //echo "<div class='query'>cache : '$query' <div>"; MyPDO::$nb_cache++; return MyPDO::$cache[$query . "::" . serialize($args)]; } MyPDO::$cache_activate = true; $reponse = parent::prepare($query); $reponse->execute($args); $err = $reponse->errorInfo(); if (@$err[2]) { if (preg_match("/Duplicate entry/", $err[2])) { return -1; } echo $err[2] . '<hr />' . $query . '<hr />'; print_r($args); return -1; } $ret = array(); while ($o = $reponse->fetch()) { array_push($ret, $o); } $reponse->closeCursor(); if (count($ret)) { MyPDO::$cache[$query . "::" . serialize($args)] = $ret; } // on cache que les requete qui retourne des resultat, insert update doit tjrs etre executé $timeend = microtime(true); $time = $timeend - $timestart; $page_load_time = number_format($time, 3); //echo '<div class="query">query: '.$query.' ('.$page_load_time.'sec)</div>'; return $ret; }
public function testPrepare() { $dbh = new MyPDO('sqlite::memory:'); $stmt = $dbh->prepare('SELECT 1'); $this->assertInstanceOf('MyPDOStatement', $stmt); }
if (preg_match('/^\\d/', $_POST['prefix']) == 0 && strlen(preg_replace('/(.*)_/', '$1', $_POST['prefix'])) <= 5) { if (ctype_alnum(preg_replace('/(.*)_/', '$1', $_POST['prefix']))) { $_POST['prefix'] = strtolower($_POST['prefix']); if (preg_match("/[a-zA-Z0-9]{1,5}_/i", $_POST['prefix'])) { $dbprefix = $_POST['prefix']; } else { $dbprefix = $_POST['prefix'] . '_'; } $_POST['prefix'] = $dbprefix; } } } } } try { $db = new MyPDO('mysql:host=' . $dbhost . ';dbname=' . $dbname, $dbuser, $dbpass, array(), $dbprefix); } catch (PDOException $e) { //echo $e->getMessage(); die(show_message($e->getMessage())); } $db->query('SET character_set_connection = ' . $sqlchar); $db->query('SET character_set_client = ' . $sqlchar); $db->query('SET character_set_results = ' . $sqlchar); $db->query('SET SESSION wait_timeout = 60;'); if (isset($_GET['multi']) and preg_match("/[a-zA-Z0-9]{1,5}/i", $_GET['multi']) and strlen($_GET['multi']) <= 5) { $tmp_prefix = $_GET['multi'] . '_'; $sql = "SELECT COUNT(id) FROM multiclan WHERE prefix = '" . $tmp_prefix . "';"; $q = $db->prepare($sql); if ($q->execute() == TRUE) { $multi = $q->fetchColumn(); } else {
<?php ini_set('session.save_path', realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/temp')); // session_start(); if (!isset($_SESSION['admin'])) { header("location:login.html"); } include_once "config/MyPDO.class.php"; $connect = new MyPDO(); $connect->query("SET NAMES 'utf8'"); $id_lcommande = $_GET['id']; $req2 = "select * from ligne_commande where id={$id_lcommande}"; $oPDOStatements2 = $connect->query($req2); // Le résultat est un objet de la classe PDOStatement $oPDOStatements2->setFetchMode(PDO::FETCH_ASSOC); //retourne true on success, false otherwise. while ($data = $oPDOStatements2->fetch()) { $id = $data['id']; $id_commande = $data['id_commande']; $id_produit = $data['id_produit']; $id_lit = $data['id_lit']; $etat_louer = $data['etat_louer']; } $req3 = "UPDATE `ligne_commande` SET `etat_louer`=0 WHERE `id`={$id_lcommande} "; $oPDOStatement3 = $connect->query($req3); if ($id_lit == 0) { $req4 = "UPDATE `produit` SET `qte_louer`=`qte_louer`-1 WHERE `id`={$id_produit} "; $oPDOStatement4 = $connect->query($req4); } if ($id_lit != 0) {
function subscriptionList() { logMe("subscriptionList()\n"); header('Content-Type: application/json; charset=UTF-8'); $pdo = new MyPDO(); $stm = $pdo->prepare('SELECT f.id, f.name, f.url, f.website, c.id as c_id, c.name as c_name FROM `%_feed` f INNER JOIN `%_category` c ON c.id = f.category'); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_ASSOC); $subscriptions = array(); foreach ($res as $line) { $subscriptions[] = array('id' => 'feed/' . $line['id'], 'title' => $line['name'], 'categories' => array(array('id' => 'user/-/label/' . $line['c_name'], 'label' => $line['c_name'])), 'url' => $line['url'], 'htmlUrl' => $line['website']); } echo json_encode(array('subscriptions' => $subscriptions)), "\n"; exit; }
<?php include_once "config/MyPDO.class.php"; $connect = new MyPDO(); $connect->query("SET NAMES 'utf8'"); if (isset($_POST["contrat"])) { $nom_client = ""; $adresse_client = ""; $tel_client = ""; $gsm_client = ""; $cin_client = ""; $date_cin = ""; $nom_ben = ""; $adresse_ben = ""; $tel_ben = ""; $cin_ben = ""; extract($_POST); if ($etage == 2) { $frais = $frais * 1.5; } elseif ($etage == 3) { $frais = $frais * 2; } elseif ($etage == 4) { $frais = $frais * 2.5; } elseif ($etage == 5) { $frais = $frais * 3; } elseif ($etage >= 6) { $frais = $frais * 3.5; } $transport = $transport * 0.6 + $frais; }
<?php ini_set('session.save_path', realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/temp')); session_start(); require 'invoice.php'; require 'config/fonctions.php'; include_once "config/MyPDO.class.php"; $connect = new MyPDO(); //************************// $today = date("d-m-Y"); $nom_client = ""; $adresse_client = ""; $tel_client = ""; $cin_client = ""; $date_cin = ""; $nom_ben = ""; $adresse_ben = ""; $tel_ben = ""; $cin_ben = ""; extract($_POST); //**************************// $id = $_GET['id']; $gsm_client = ""; $req1 = "SELECT * FROM `commande` WHERE `id`={$id}; "; $oPDOStatement = $connect->query($req1); // Le résultat est un objet de la classe PDOStatement $oPDOStatement->setFetchMode(PDO::FETCH_OBJ); while ($row = $oPDOStatement->fetch()) { $id = $row->id; $ref = $row->ref; $nom_client = $row->nom_client;
<?php include_once "/var/www/html/xlinkdb/db/MyPDO.php"; $dbaccess = new MyPDO(); $jobs = $dbaccess->prepare("select * from jobdb where `name`='model' and `status`='ongoing'"); $jobs->execute(); while ($job = $jobs->fetch()) { $folderPath = "/home/czheng/jenkins_workspace/" . $job['proA']; if (file_exists($folderPath . $job['proA'] . ".pdb")) { $updateJob = $dbaccess->prepare("update jobdb set `status`='complete' where `job_id`=" . $job['job_id']); $updateJob->execute(); //move file system("cp " . $folderPath . $job['proA'] . ".pdb /var/www/html/xlinkdb/pdb/"); //update database $needUpdate = $dbaccess->prepare("select cross_linkID, kposA, startPosA from xlinkdb where proA='" . $job['proA'] . "'"); $needUpdate->execute(); while ($update = $needUpdate->fetch()) { $residue = intval($update['kposA']) + intval($update['startPosA']) + 1; $pdb = fopen($folderPath . $job['proA'] . ".pdb", "r"); $atomNumber = "####"; while ($line = fgets($pdb)) { if (strlen($line) < 54) { continue; } $res = intval(substr($line, 22, 4)); if (substr($line, 0, 4) === "ATOM" and $res === $residue and substr($line, 12, 2) === "CA") { $atomNumber = substr($line, 6, 5); } } fclose($pdb); $executeUpdate = $dbaccess->prepare("update xlinkdb \n set pdbA='" . $job['proA'] . "' siteA='" . $residue . ":A' atomNumA='" . $atomNumber . "' \n where `cross_linkID`=" . $update['cross_linkID']);
/** @fn dbconn($fnConfirm=$GLOBALS["dbConfirmFn"]) @param fnConfirm fn(dbConnectionString), 如果返回false, 则程序中止退出。 @key dbConfirmFn 连接数据库前回调。 连接数据库 数据库由全局变量$DB(或环境变量P_DB)指定,格式可以为: host1/carsvc (无扩展名,表示某主机host1下的mysql数据库名;这时由 全局变量$DBCRED 或环境变量 P_DBCRED 指定用户名密码。 dir1/dir2/carsvc.db (以.db文件扩展名标识的文件路径,表示SQLITE数据库) 环境变量 P_DBCRED 指定用户名密码,格式为 base64(dbuser:dbpwd). */ function dbconn($fnConfirm = null) { global $DBH; if (isset($DBH)) { return $DBH; } global $DB, $DBCRED, $USE_MYSQL; // e.g. P_DB="../carsvc.db" if (!$USE_MYSQL) { $C = ["sqlite:" . $DB, '', '']; } else { // e.g. P_DB="115.29.199.210/carsvc" // e.g. P_DB="115.29.199.210:3306/carsvc" if (!preg_match('/^"?(.*?)(:(\\d+))?\\/(\\w+)"?$/', $DB, $ms)) { throw new MyException(E_SERVER, "bad db=`{$DB}`", "未知数据库"); } $dbhost = $ms[1]; $dbport = $ms[3] ?: 3306; $dbname = $ms[4]; list($dbuser, $dbpwd) = getCred($DBCRED); $C = ["mysql:host={$dbhost};dbname={$dbname};port={$dbport}", $dbuser, $dbpwd]; } if ($fnConfirm == null) { @($fnConfirm = $GLOBALS["dbConfirmFn"]); } if ($fnConfirm && $fnConfirm($C[0]) === false) { exit; } try { $DBH = new MyPDO($C[0], $C[1], $C[2]); } catch (PDOException $e) { $msg = $GLOBALS["TEST_MODE"] ? $e->getMessage() : "dbconn fails"; throw new MyException(E_DB, $msg, "数据库连接失败"); } if ($USE_MYSQL) { $DBH->exec('set names utf8'); } $DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); # by default use PDO::ERRMODE_SILENT # enable real types (works on mysql after php5.4) # require driver mysqlnd (view "PDO driver" by "php -i") $DBH->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $DBH->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); return $DBH; }
<?php include_once "/var/www/html/xlinkdb/db/MyPDO.php"; $dbaccess = new MyPDO(); $jobs = $dbaccess->prepare("select * from jobdb where `name`='docking' and `status`='ongoing'"); $jobs->execute(); while ($job = $jobs->fetch()) { $folderPath = "/home/czheng/jenkins_workspace/" . $job['proA'] . "_" . $job['proB'] . "/"; if (file_exists($folderPath . $job['proA'] . "_" . $job['proB'] . ".pdb")) { $updateJob = $dbaccess->prepare("update jobdb set `status`='complete' where `job_id`=" . $job['job_id']); $updateJob->execute(); //move file system("cp " . $folderPath . $job['proA'] . "_" . $job['proB'] . ".pdb /var/www/html/xlinkdb/pdb/"); //update database $needUpdate = $dbaccess->prepare("select * from xlinkdb where proA='" . $job['proA'] . "' and proB='" . $job['proB'] . "'"); $needUpdate->execute(); while ($update = $needUpdate->fetch()) { $residueA = intval($update['kposA']) + intval($update['startPosA']) + 1; $residueB = intval($update['kposB']) + intval($update['startPosB']) + 1; $pdb = fopen($folderPath . $job['proA'] . "_" . $job['proB'] . ".pdb", "r"); $pdbCode = $job['proA'] . "_" . $job['proB']; $atomNumberA = "####"; $atomNumberB = "####"; $coodsA = array("x" => 0, "y" => 0, "z" => 0); $coodsB = array("x" => 0, "y" => 0, "z" => 0); while ($line = fgets($pdb)) { $res = intval(substr($line, 22, 4)); if (substr($line, 0, 4) === "ATOM" and $res === $residue and substr($line, 21, 1) === "A" and substr($line, 12, 2) === "CA") { $atomNumberA = substr($line, 6, 5); $coodsA['x'] = intval($line, 30, 8); $coodsA['y'] = intval($line, 38, 8);
<?php /** * Created by PhpStorm. * User: Racem * Date: 16/01/2016 * Time: 16:24 */ $id_prod = $_GET["id"]; ini_set('session.save_path', realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/temp')); session_start(); extract($_POST); include_once "config/MyPDO.class.php"; $connect = new MyPDO(); $connect->query("SET NAMES 'utf8'"); $req1 = "SELECT * FROM `produit` WHERE `id`={$id_prod} "; $oPDOStatement = $connect->query($req1); // Le résultat est un objet de la classe PDOStatement $oPDOStatement->setFetchMode(PDO::FETCH_OBJ); while ($row = $oPDOStatement->fetch()) { $id = $row->id; $nom = $row->nom; $ref = $row->ref; $prix_semaine = $row->prix_semaine; $prix_mois = $row->prix_mois; $qte = $row->qte; $qte_louer = $row->qte_louer; $caution = $row->caution; $tva_produit = $row->tva_produit; $type = $row->type; }
*/ get_header(); require 'wp-content/plugins/MyPlugin/class/MyPDO.php'; require_once 'wp-content/plugins/MyPlugin/inc/functions.php'; $p=1; $nb_display = 50; if(isset($_GET["pagin"]) && is_numeric($_GET["pagin"])){ $p=$_GET["pagin"]; } $q = simple_format($_GET["q"]); if(!$q){ $q='jeuxenpromotion'; } $bdd = new MyPDO(); $sql ='SELECT SQL_CALC_FOUND_ROWS * from game where simple_titre like(\'%'.$q.'%\') order by creato desc, percent desc, prix_apres asc LIMIT '.(($p-1)*$nb_display).','.$nb_display; $data = null; $ret = $bdd->query($sql, $data ); $ret_max = $bdd->query('SELECT FOUND_ROWS() as max_result'); $max = (int) $ret_max[0]->max_result; if(count($ret)<$max){ $pagination = true; $max_page = ceil($max/$nb_display); } $s=''; if($max>1){
} function report() { global $template; $at = explode(' ', START_TIME); $bt = explode(' ', microtime()); $temps = floor(1000 * ($bt[1] - $at[1] + $bt[0] - $at[0])) / 1000.0; $template->assign_block_vars('DEBUG', array('NB_REQUETES' => $this->nb_query, 'TEMPS' => $temps)); foreach ($this->queries as $q) { $template->assign_block_vars('DEBUG.REQ', array('SQL' => $q)); } } } // Connection à la base de données try { $db = new MyPDO($conf['db_dsn'], $conf['db_user'], $conf['db_passwd'], array(PDO::ATTR_PERSISTENT => $conf['db_persistent'])); } catch (PDOException $e) { $template = new Template('data/templates/' . $conf['default_template']); $template->set_filenames(array('root' => 'root.tpl')); $template->assign_var('TITRE', $conf['titre']); $template->assign_var('TEMPLATE_URL', 'data/templates/' . $conf['default_template']); $template->assign_block_vars('MSG_ERREUR', array('DESCR' => 'Erreur : impossible de se connecter à la base de données !<br/> Erreur : ' . $e->getMessage())); header('500 Internal Server Error'); header('Content-type: text/html; charset=utf-8'); $template->pparse('root'); exit(1); } // Identification de l'utilisateur $utilisateur = new Utilisateur(); // Choix du module
<meta charset="utf-8" /> <?php echo "\n" . '--check_mail' . "\n\n"; echo "\nDebut du script: " . date("H:i:s", microtime(true)) . "\n"; require_once 'inc/functions.php'; require_once 'class/MyPDO.php'; $bdd = new MyPDO(); $ret = $bdd->query("select post_id, GROUP_CONCAT( concat(meta_key,':',meta_value) SEPARATOR ' ▬ ' ) as data from wpromo_postmeta where post_id in (SELECT post_id FROM `wpromo_postmeta` WHERE `meta_key`='_field_24' and `meta_value`='oui') AND meta_key in ('_field_18', '_field_20', '_field_19', '_field_21', '_field_17') GROUP BY post_id"); $nb_result = count($ret); foreach ($ret as $toMail) { echo 'q:' . $toMail->data . "\n"; preg_match('/_field_17:([^▬]+)/', $toMail->data, $matches); $nom = trim($matches[1]); preg_match('/_field_18:([^▬]+)/', $toMail->data, $matches); $email = trim($matches[1]); preg_match('/_field_20:([^▬]+)/', $toMail->data, $matches); $tag = trim($matches[1]); preg_match('/_field_19:([^▬]+)/', $toMail->data, $matches); $euro = trim($matches[1]); preg_match('/_field_21:([^▬]+)/', $toMail->data, $matches); $percent = trim($matches[1]); $id = $toMail->post_id; echo $id . ' ' . $email . ' ' . $tag . ' ' . $euro . '€ ' . $percent . '%' . "\n"; if (!$id) { continue; } $mot_cles = explode(' ', $tag); $nb_result_total = 0; foreach ($mot_cles as $mot_cle) { $mot_cle = simple_format($mot_cle); echo ' - recherche de ' . $mot_cle . "\n";
private static function concatData($table, $column, $value, $where) { if (!self::hasIP(true)) { return; } $query = 'UPDATE ' . $table . ' SET ' . $column . ' = CONCAT(' . $column . ',",' . $value . '") WHERE ' . $where; MyPDO::get()->query($query); }
<?php /** * Template Name: Promo */ get_header(); $myPost = $post; $nb_display = 50; /*$p=1; if(isset($_GET["pagin"]) && is_numeric($_GET["pagin"])){ $p=$_GET["pagin"]; }*/ $p = (get_query_var('page')) ? get_query_var('page') : 1; require 'wp-content/plugins/MyPlugin/class/MyPDO.php'; $bdd = new MyPDO(); $sql = 'SELECT SQL_CALC_FOUND_ROWS * from game where creato=? order by percent desc, prix_apres asc, titre LIMIT '.(($p-1)*$nb_display).','.$nb_display; $param = date('Y-m-d'); $ret = $bdd->query($sql, array($param)); $ret_max = $bdd->query('SELECT FOUND_ROWS() as max_result'); $max = (int) $ret_max[0]->max_result; if(count($ret)<$max){ $pagination = true; $max_page = ceil($max/$nb_display); } ?>
/** * Search users by part of fio * @param type $term * @return type */ public static function findAll($term) { $sql = 'select * from `users` where fio like "%' . $term . '%"'; $instance = MyPDO::getInstance(); return $instance->query($sql); }
<?php include_once "config/MyPDO.class.php"; $connect = new MyPDO(); //$connect->query("SET NAMES 'utf8'"); $req1 = "SELECT MAX(`ref_lit`)AS max_lit,MAX(`ref_moteur_p`)AS max_moteur_p, MAX(`ref_moteur_s`)AS max_moteur_s, MAX(`ref_telecommande`) AS max_telecommande FROM `lit`"; $oPDOStatement = $connect->query($req1); // Le résultat est un objet de la classe PDOStatement $oPDOStatement->setFetchMode(PDO::FETCH_OBJ); while ($row = $oPDOStatement->fetch()) { $max_lit = $row->max_lit + 1; $max_moteur_p = $row->max_moteur_p + 1; $max_moteur_s = $row->max_moteur_s + 1; $max_telecommande = $row->max_telecommande + 1; } if ($max_lit < 10) { $max_lit = "00" . $max_lit; } elseif ($max_lit < 100 && $max_lit >= 10) { $max_lit = "0" . $max_lit; } if ($max_moteur_p < 10) { $max_moteur_p = "00" . $max_moteur_p; } elseif ($max_moteur_p < 100 && $max_moteur_p >= 10) { $max_moteur_p = "0" . $max_moteur_p; } if ($max_moteur_s < 10) { $max_moteur_s = "00" . $max_moteur_s; } elseif ($max_moteur_s < 100 && $max_moteur_s >= 10) { $max_moteur_s = "0" . $max_moteur_s; }
/** * @expectedException BadMethodCallException */ public function testBadMethodCall() { $dbh = new MyPDO('sqlite::memory:'); $dbh->foobar(); }
<?php if (!headers_sent()) { header('Content-Type: text/html; charset=utf-8'); } require_once 'inc/functions.php'; require_once 'class/MyPDO.php'; require_once 'devise.php'; $bdd = new MyPDO(); $p = 0; echo "\n" . '--robot_humblebundle' . "\n\n"; echo "\nDebut du script: " . date("H:i:s", microtime(true)) . "\n"; $nb_result_total = 0; do { $file = 'https://www.humblebundle.com/store/api?request=1&page_size=20&sort=discount&platform=windows&page=' . $p; //echo $file.'<br />'; $homepage = @file_get_contents($file); $homepage = mb_convert_encoding($homepage, 'UTF-8', 'iso-8859-1'); $homepage = utf8_decode($homepage); $homepage = json_decode($homepage); $nb_result = count(@$homepage->results); $nb_result_total += $nb_result; $total_global += $nb_result; for ($i = 0; $i < $nb_result; $i++) { $titre = trim($homepage->results[$i]->human_name); $simple_titre = simple_format($titre); $link = 'https://www.humblebundle.com/store/p/' . trim($homepage->results[$i]->machine_name); $photo = 'https://www.humblebundle.com' . trim($homepage->results[$i]->storefront_featured_image_small); $prix_avant = str_replace(',', '.', $homepage->results[$i]->full_price[0]); $taux_full_price = @$taux[$homepage->results[$i]->full_price[1]]; if (!$taux_full_price) {