コード例 #1
0
 /**
  * Perform term count update immediately.
  *
  * @since 2.5.0
  *
  * @param array $terms The term_taxonomy_id of terms to update.
  * @param string $taxonomy The context of the term.
  * @return bool Always true when complete.
  */
 function update_term_count_now($terms, $taxonomy)
 {
     $terms = array_map('intval', $terms);
     $taxonomy = $this->get_taxonomy($taxonomy);
     if (!empty($taxonomy->update_count_callback)) {
         call_user_func($taxonomy->update_count_callback, $terms);
     } else {
         // Default count updater
         foreach ((array) $terms as $term) {
             $count = $this->db->get_var($this->db->prepare("SELECT COUNT(*) FROM {$this->db->term_relationships} WHERE term_taxonomy_id = %d", $term));
             $this->db->update($this->db->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
         }
     }
     $this->clean_term_cache($terms);
     return true;
 }
コード例 #2
0
ファイル: PDO.php プロジェクト: nurulimamnotes/DewiSriDesktop
 /**
  * (non-PHPdoc)
  * @see RedBean/RedBean_Driver#Execute()
  */
 public function Execute($sql, $aValues = array())
 {
     $this->exc = 0;
     if ($this->debug) {
         echo "<HR>" . $sql . print_r($aValues, 1);
     }
     try {
         $s = $this->pdo->prepare($sql);
         $s->execute($aValues);
         $this->affected_rows = $s->rowCount();
         return $this->affected_rows;
     } catch (PDOException $e) {
         //Unfortunately the code field is supposed to be int by default (php)
         //So we need a property to convey the SQL State code
         $x = new RedBean_Exception_SQL($e->getMessage(), 0, $e);
         $x->setSQLState($e->getCode());
         throw $x;
     }
     //
 }
コード例 #3
0
ファイル: Model.php プロジェクト: wamania/mynd-framework
 /**
  * Show columns of current table
  *
  * @return Array
  */
 public function queryColumns()
 {
     if (empty(self::$cache[static::$table])) {
         // temporaire...
         if ($this->db->getDriver() == 'mysql') {
             $s = $this->db->query("SHOW COLUMNS FROM " . static::$table);
         } elseif ($this->db->getDriver() == 'pgsql') {
             $s = $this->db->prepare("SELECT column_name AS field FROM information_schema.columns WHERE table_name=?");
             $s->execute(array(static::$table));
         }
         if ($s->rowCount() <= 0) {
             throw new LiException('La table ' . $table . ' ne contient aucune colonne');
         }
         $rs = $s->fetchAll();
         $fields = array();
         foreach ($rs as $row) {
             $fields[] = $row['field'];
         }
         self::$cache[static::$table] = $fields;
     }
     return self::$cache[static::$table];
 }
コード例 #4
0
/**
 * get the homologue ensemble ids of the target species to a given set of ensebl ids.
 *
 * @param unknown_type $compara
 * @param unknown_type $unique_ids
 * @param target_genome_db_id the genome of the target species for filtering (speed up)
 */
function get_homologue_ens_ids_slow($compara, $unique_ids, $target_genome_db_id)
{
    $homology = array();
    $sql = 'SELECT m.stable_id,hom.description FROM homology AS hom,member AS m inner join homology_member AS h
		ON (m.member_id = h.member_id
		AND h.homology_id = hom.homology_id 
		AND m.genome_db_id = ?)
		INNER join homology_member AS h2
		ON h.homology_id = h2.homology_id
		INNER join member AS m2
		ON m2.member_id = h2.member_id AND m2.stable_id = ?
		GROUP BY m.stable_id;';
    $stmt = $compara->prepare($sql);
    foreach ($unique_ids as $unique_id) {
        /* bind parameters for markers */
        $stmt->bind_param("is", $target_genome_db_id, $unique_id);
        /* execute query */
        $stmt->execute();
        /* bind result variables */
        $stmt->bind_result($homo_id, $homo_descript);
        $homology[$unique_id] = array();
        /* fetch value */
        while ($stmt->fetch()) {
            $homology[$unique_id][] = $homo_id;
            $homology[$unique_id][$homo_id] = $homo_descript;
        }
        /*$result = $compara->query($sql) or fatal_error('Homology query failed: '.$compara->error);
        	 $members = array();
        	 while ($row = $result->fetch_assoc()){
        		$members[] = $row['stable_id'];
        		}
        		$homology[$unique_id] = $members;*/
    }
    /* close statement */
    $stmt->close();
    return $homology;
}
コード例 #5
0
ファイル: rb127lg.php プロジェクト: nev3rm0re/hondex
 /**
  * (non-PHPdoc)
  * @see RedBean/RedBean_Driver#Execute()
  */
 public function Execute($sql, $aValues = array())
 {
     $this->connect();
     $this->exc = 0;
     if ($this->debug) {
         echo "<HR>" . $sql . print_r($aValues, 1);
     }
     try {
         if (strpos("pgsql", $this->dsn) === 0) {
             $s = $this->pdo->prepare($sql, array(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => true));
         } else {
             $s = $this->pdo->prepare($sql);
         }
         $s->execute($aValues);
         $this->affected_rows = $s->rowCount();
         return $this->affected_rows;
     } catch (PDOException $e) {
         if (version_compare(PHP_VERSION, '5.3.0', '<')) {
             $x = new RedBean_Exception_SQL($e->getMessage(), 0);
         } else {
             $x = new RedBean_Exception_SQL($e->getMessage(), 0, $e);
         }
         $x->setSQLState($e->getCode());
         throw $x;
     }
 }
コード例 #6
0
ファイル: rb.php プロジェクト: u007/FlexiPHP
 /**
  * (non-PHPdoc)
  * @see RedBean/RedBean_Driver#Execute()
  */
 public function Execute($sql, $aValues = array())
 {
     //FlexiLogger::error(__METHOD__, "SQL: " . $sql);
     $this->exc = 0;
     if ($this->debug) {
         echo "<HR>" . $sql . print_r($aValues, 1);
     }
     try {
         if (strpos("pgsql", $this->dsn) === 0) {
             $s = $this->pdo->prepare($sql, array(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => true));
         } else {
             $s = $this->pdo->prepare($sql);
         }
         $s->execute($aValues);
         $this->affected_rows = $s->rowCount();
         return $this->affected_rows;
     } catch (PDOException $e) {
         //Unfortunately the code field is supposed to be int by default (php)
         //So we need a property to convey the SQL State code.
         FlexiLogger::error(__METHOD__, "SQL: " . $sql . ", error: " . $e->getMessage());
         if (version_compare(PHP_VERSION, '5.3.0', '<')) {
             $x = new RedBean_Exception_SQL($e->getMessage(), 0);
         } else {
             $x = new RedBean_Exception_SQL($e->getMessage(), 0, $e);
         }
         $x->setSQLState($e->getCode());
         throw $x;
     }
     //
 }
コード例 #7
0
ファイル: cc128.php プロジェクト: ka2er/cc128-php-extractor
/**
 *
 * @param unknown_type $db
 * @param unknown_type $tstamp
 * @param unknown_type $kwatt
 */
function addOrUpdateValue($db, $tstamp, $kwatt)
{
    $st = $db->prepare('REPLACE INTO consumption (date, kwatt) values (:date, :kwatt)');
    $st->bindParam(':date', $tstamp);
    $st->bindParam(':kwatt', $kwatt);
    $st->execute();
}