本文整理汇总了PHP中MDB2::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2::prepare方法的具体用法?PHP MDB2::prepare怎么用?PHP MDB2::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2
的用法示例。
在下文中一共展示了MDB2::prepare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _PrepareAndExecute
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: setUpStatements
/**
* 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: updateMonth
/**
* 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);
}