本文整理汇总了PHP中ORM::_last_statement方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::_last_statement方法的具体用法?PHP ORM::_last_statement怎么用?PHP ORM::_last_statement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::_last_statement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _execute
/**
* Internal helper method for executing statments. Logs queries, and
* stores statement object in ::_last_statment, accessible publicly
* through ::get_last_statement()
* @param string $query
* @param array $parameters An array of parameters to be bound in to the query
* @param string $connection_name Which connection to use
* @return bool Response of PDOStatement::execute()
*/
protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION)
{
self::_log_query($query, $parameters, $connection_name);
$statement = self::$_db[$connection_name]->prepare($query);
self::$_last_statement = $statement;
return $statement->execute($parameters);
}
示例2: _execute
/**
* Internal helper method for executing statments. Logs queries, and
* stores statement object in ::_last_statment, accessible publicly
* through ::get_last_statement()
* @param string $query
* @param array $parameters An array of parameters to be bound in to the query
* @param string $connection_name Which connection to use
* @return bool Response of PDOStatement::execute()
*/
protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION)
{
$statement = self::get_db($connection_name)->prepare($query);
self::$_last_statement = $statement;
$time = microtime(true);
foreach ($parameters as $key => &$param) {
if (is_null($param)) {
$type = PDO::PARAM_NULL;
} else {
if (is_bool($param)) {
$type = PDO::PARAM_BOOL;
} else {
if (is_int($param)) {
$type = PDO::PARAM_INT;
} else {
$type = PDO::PARAM_STR;
}
}
}
$statement->bindParam(is_int($key) ? ++$key : $key, $param, $type);
}
$q = $statement->execute();
self::_log_query($query, $parameters, $connection_name, microtime(true) - $time);
return $q;
}
示例3: _execute
/**
* Internal helper method for executing statments. Logs queries, and
* stores statement object in ::_last_statment, accessible publicly
* through ::get_last_statement()
* @param string $query
* @param array $parameters An array of parameters to be bound in to the query
* @param string $connection_name Which connection to use
* @return bool Response of PDOStatement::execute()
*/
protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION)
{
$statement = self::get_db($connection_name)->prepare($query);
self::$_last_statement = $statement;
$time = microtime(true);
$count = count($parameters);
for ($i = 0; $i < $count; $i++) {
$type = PDO::PARAM_STR;
if (is_null($parameters[$i])) {
$type = PDO::PARAM_NULL;
}
if (is_bool($parameters[$i])) {
$type = PDO::PARAM_BOOL;
}
if (is_int($parameters[$i])) {
$type = PDO::PARAM_INT;
}
$statement->bindParam($i + 1, $parameters[$i], $type);
}
$q = $statement->execute();
self::_log_query($query, $parameters, $connection_name, microtime(true) - $time);
return $q;
}