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; }
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 "/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 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']);
$_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 { die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql)); } if ($multi == 1) { $db->change_prefix($tmp_prefix); } else { unset($_GET['multi']); } }
public function testPrepare() { $dbh = new MyPDO('sqlite::memory:'); $stmt = $dbh->prepare('SELECT 1'); $this->assertInstanceOf('MyPDOStatement', $stmt); }
<?php ini_set('session.save_path', realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/temp')); session_start(); //On pr�pare l'utilisation des variables de fonctions (variable qui sont stock�es sur le serveur pour chaque session ouverte) //session_start(); // Fichier auth.php include_once "config/MyPDO.class.php"; $connect = new MyPDO(); // On int�gre les informations de connexion � la base de donn�es ainsi que le fichier (ou librairie fonctions.php) // On r�cup�re ce que l'utilisateur � saisi, si il n'a rien saisi (login ou mot de passe) on le renvoi sur la page de cr�ation de compte //$pass=md5($pass); $AfficherFormulaire = TRUE; if (!empty($_POST['pseudo']) and !empty($_POST['MotDePasse'])) { $req = $connect->prepare('SELECT COUNT(*),TYPE FROM users WHERE password = :MotDePasse AND login = :pseudo'); $req->bindValue(':pseudo', $_POST['pseudo'], PDO::PARAM_STR); $req->bindValue(':MotDePasse', $_POST['MotDePasse'], PDO::PARAM_STR); $req->execute(); $resultat = $req->fetch(); $req->closeCursor(); if ($resultat[0] == 0) { echo "<SCRIPT LANGUAGE='JavaScript'>\n alert('login ou mot de passe incorrect');\n self.parent.location.href='login.html';\n </SCRIPT> "; } if ($resultat[0] != 0 && $resultat[1] == 0) { $_SESSION['pseudo'] = $_POST['pseudo']; $_SESSION['password'] = $_POST['MotDePasse']; $_SESSION['admin'] = "auth_ok"; $_SESSION['superadmin'] = "auth_ok"; header("location: acceuil.php"); $AfficherFormulaire = FALSE; } elseif ($resultat[0] != 0 && $resultat[1] == 1) {
public function getFeeds() { $cat_id = $this->param('cat_id'); $unread_only = $this->param('unread_only', false); $limit = (int) $this->param('limit', -1); $offset = (int) $this->param('offset', -1); // $include_nested = $this->param('include_nested', false) === true; // not supported $sql_values = array(); $sql_where = ''; if ($cat_id >= 0) { // special ids are not supported (yet?) $sql_where = ' WHERE f.category = ?'; $sql_values[] = $cat_id; } $sql_limit = ''; if ($limit >= 0 && $offset >= 0) { $sql_limit = ' LIMIT ? OFFSET ?'; $sql_values[] = $limit; $sql_values[] = $offset; } $pdo = new MyPDO(); $sql = 'SELECT f.id, f.name, f.url, f.category, f.cache_nbUnreads AS unread, f.lastUpdate' . ' FROM `%_feed` f' . $sql_where . $sql_limit; $stm = $pdo->prepare($sql); $stm->execute($sql_values); $res = $stm->fetchAll(PDO::FETCH_ASSOC); $feeds = array(); foreach ($res as $feed) { if ($unread_only && $feed['unread'] <= 0) { continue; } $feeds[] = array('id' => $feed['id'], 'title' => $feed['name'], 'feed_url' => $feed['url'], 'unread' => $feed['unread'], 'has_icon' => true, 'cat_id' => $feed['category'], 'last_updated' => $feed['lastUpdate']); } $this->good($feeds); }