本文整理汇总了PHP中PDOStatement::closeCursor方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOStatement::closeCursor方法的具体用法?PHP PDOStatement::closeCursor怎么用?PHP PDOStatement::closeCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOStatement
的用法示例。
在下文中一共展示了PDOStatement::closeCursor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispose
public function dispose()
{
if (!$this->is_disposed) {
$this->statement->closeCursor();
$this->is_disposed = true;
}
}
示例2: flush
/**
* Free memory associated with the resultset
*
* @return void
*/
public function flush()
{
if ($this->result instanceof PDOStatement) {
$this->result->closeCursor();
}
$this->result = null;
$this->col_info = null;
$this->fetched_rows = array();
}
示例3: found_rows
/** SELECT FOUND_ROWS() after query with SQL_CALC_FOUND_ROWS
* @return int
*/
public function found_rows()
{
if (is_null($this->_fr_stmt)) {
$this->_fr_stmt = $this->prepare('SELECT FOUND_ROWS();');
}
$this->_fr_stmt->execute();
$rows_count = $this->_fr_stmt->fetchColumn(0);
$this->_fr_stmt->closeCursor();
return $rows_count;
}
示例4: fetch
public function fetch()
{
$this->executeQuery();
if ($this->fetchResults === null) {
$this->fetchResults = $this->statement->fetchAll(PDO::FETCH_ASSOC);
$this->statement->closeCursor();
}
if (array_key_exists($this->currentFetchIndex, $this->fetchResults) && $this->fetchResults[$this->currentFetchIndex] !== null) {
return $this->fetchResults[$this->currentFetchIndex++];
}
return false;
}
示例5: query
/**
* Run a query against a database. Get a result
* @param string $query The SQL to run against the database
* @param array $args An associative array of query parameters
* @return bool|\PDOStatement False if query fails, results in this database's fetch_class if successful
* @throws \Exception
*/
public function query($query, $args = array())
{
if (!empty($this->pdo_statement)) {
$this->pdo_statement->closeCursor();
}
if ($this->pdo_statement = $this->prepare($query, array(PDO::ATTR_EMULATE_PREPARES => true))) {
$this->pdo_statement->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, $this->fetch_class, [$this]);
if (!$this->pdo_statement->execute($args)) {
throw new \Exception($this->pdo_statement->errorInfo());
}
return true;
} else {
throw new \Exception($this->errorInfo());
}
}
示例6: closeCursor
public function closeCursor()
{
if ($this->_statement instanceof \PDOStatement) {
return $this->_statement->closeCursor();
}
return false;
}
示例7: finish
/**
* Close the statement handle
**/
public function finish()
{
if ($this->sh && is_object($this->sh)) {
$this->sh->closeCursor();
}
unset($this->sh);
}
示例8: freeResult
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return bool Returns true on success, false on failure.
*/
public function freeResult()
{
if ($this->resourceHandle === null) {
return false;
}
$this->resourceHandle->closeCursor();
return true;
}
示例9: freeResult
/**
* Frees the memory associated with a result.
* Provides a fluent interface.
*
* @return PDOMySQL
*/
public function freeResult()
{
if (isset($this->result)) {
$this->result->closeCursor();
unset($this->result);
}
return $this;
}
示例10: query
/**
* Execute a SQL statement.
*
* @param string $query the SQL statement
* @param array $args values for the bound parameters
* @return boolean true on success, false on failure
*/
public function query($query, $args = array())
{
if ($this->pdo_statement != null) {
$this->pdo_statement->closeCursor();
}
// Allow plugins to modify the query
$query = Plugins::filter('query', $query, $args);
// Translate the query for the database engine
$query = $this->sql_t($query, $args);
// Replace braced table names in the query with their prefixed counterparts
$query = self::filter_tables($query);
// Allow plugins to modify the query after it has been processed
$query = Plugins::filter('query_postprocess', $query, $args);
if ($this->pdo_statement = $this->pdo->prepare($query)) {
if ($this->fetch_mode == \PDO::FETCH_CLASS) {
/* Try to get the result class autoloaded. */
if (!class_exists($this->fetch_class_name, true)) {
$class_name = $this->fetch_class_name;
// @todo This is a GIANT namespace kludge, replacing Model class names with no namespace that don't exist with a default prefixed class
if (strpos($class_name, '\\') == false) {
$class_name = '\\Habari\\' . $class_name;
$this->fetch_class_name = $class_name;
if (!class_exists($this->fetch_class_name, true)) {
throw new \Exception('The model class that was specified for data retreival could not be loaded.');
}
}
}
/* Ensure that the class is actually available now, otherwise segfault happens (if we haven't died earlier anyway). */
if (class_exists($this->fetch_class_name)) {
$this->pdo_statement->setFetchMode(\PDO::FETCH_CLASS, $this->fetch_class_name, array());
} else {
/* Die gracefully before the segfault occurs */
echo '<br><br>' . _t('Attempt to fetch in class mode with a non-included class') . '<br><br>';
return false;
}
} else {
$this->pdo_statement->setFetchMode($this->fetch_mode);
}
/* If we are profiling, then time the query */
if ($this->keep_profile) {
$profile = new QueryProfile($query);
$profile->params = $args;
$profile->start();
}
if (!$this->pdo_statement->execute($args)) {
$this->add_error(array('query' => $query, 'error' => $this->pdo_statement->errorInfo()));
return false;
}
if ($this->keep_profile) {
$profile->stop();
$this->profiles[] = $profile;
}
return true;
} else {
$this->add_error(array('query' => $query, 'error' => $this->pdo->errorInfo()));
return false;
}
}
示例11: __construct
/**
* Hook the result-set given into a Query class, suitable for use by SilverStripe.
* @param PDOStatement $statement The internal PDOStatement containing the results
*/
public function __construct(PDOStatement $statement)
{
$this->statement = $statement;
// Since no more than one PDOStatement for any one connection can be safely
// traversed, each statement simply requests all rows at once for safety.
// This could be re-engineered to call fetchAll on an as-needed basis
$this->results = $statement->fetchAll(PDO::FETCH_ASSOC);
$statement->closeCursor();
}
示例12: reset
protected function reset()
{
if ($this->stmt != null) {
$this->stmt->closeCursor();
}
$this->stmt = null;
$this->resultSet = null;
$this->updateCount = -1;
}
示例13: closeCursor
/**
* Closes the cursor, allowing the statement to be executed again.
*
* @return bool
* @throws Zend_Db_Statement_Exception
*/
public function closeCursor()
{
try {
return $this->_stmt->closeCursor();
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
}
}
示例14: close
/**
* Close the connection
*/
public function close()
{
// see: http://php.net/manual/en/pdo.connections.php#114822
if (isset($this->query)) {
$this->query->closeCursor();
}
$this->query = null;
$this->connection = null;
}
示例15: beginTransaction
public function beginTransaction()
{
if ($this->transactionNestingLevel == 0 && !$this->db->inTransaction()) {
if ($this->stmt) {
$this->stmt->closeCursor();
}
$this->db->beginTransaction();
}
$this->transactionNestingLevel++;
}