コード例 #1
0
ファイル: Mdb2Connection.php プロジェクト: Trideon/gigolo
 public function _PrepareAndExecute(ISqlCommand &$sqlCommand, $prepareType)
 {
     $cmd = new Mdb2CommandAdapter($sqlCommand);
     $stmt =& $this->_db->prepare($cmd->GetQuery(), true, $prepareType);
     if (MDB2::isError($stmt)) {
         throw new Exception('Error preparing MDB2 command. Query=%s. Error=%s', $sqlCommand->__toString(), $stmt->getMessage());
     }
     $result =& $stmt->execute($cmd->GetValues());
     if (MDB2::isError($result)) {
         throw new Exception('Error executing MDB2 command. Query=%s. Error=%s', $sqlCommand->__toString(), $stmt->getMessage());
     }
     return new Mdb2Reader($result);
 }
コード例 #2
0
 /**
  * Set up a cache of prepared statements.
  * @return MDB2_Statement_Common
  */
 protected function setUpStatements()
 {
     $this->db_statements = array();
     $this->db_statements['retrieve_type_val'] = $this->db->prepare("SELECT type,value FROM config_alt WHERE path_hash = ? LIMIT 1", array('text'), array('integer', 'text'));
     $this->db_statements['retrieve_children'] = $this->db->prepare("SELECT name as children  FROM config_alt WHERE parent = ? ", array('text'), array('text'));
     $this->db_statements['retrieve_type_val_children'] = $this->db->prepare("SELECT n.type AS type,n.value AS value, GROUP_CONCAT(c.name SEPARATOR '/') as children FROM config_alt n  LEFT JOIN config_alt c ON " . "c.parent = IF(n.parent = '/', CONCAT('/',n.name), CONCAT(n.parent,'/',n.name)) WHERE n.path_hash = ? GROUP BY type, value LIMIT 1", array('text'), array('integer', 'text', 'text'));
     $this->db_statements['store'] = $this->db->prepare("REPLACE INTO config_alt  (  path_hash, parent , name , type, value) VALUES ( ?,?, ?, ?, ? )", array('text', 'text', 'text', 'integer', 'text'));
     $this->db_statements['destroy'] = $this->db->prepare("DELETE  FROM config_alt WHERE path_hash = ? LIMIT 1", array('text'), MDB2_PREPARE_RESULT);
     foreach ($this->db_statements as $type => $db_stmt) {
         if (PEAR::isError($db_stmt)) {
             unset($this->db_statements[$type]);
         }
     }
 }
コード例 #3
0
 /**
  * Update month data
  * 
  * @param array $data
  * 
  * @return boolean
  */
 private function updateMonth($data)
 {
     $stmt = $this->_db->prepare("UPDATE `article_months` SET `Months_count` = ? WHERE `Months_year` = ? AND `Months_Number` = ?", array('integer', 'integer', 'integer'), MDB2_PREPARE_MANIP);
     return $affectedRows = $stmt->execute($data);
 }