本文整理汇总了PHP中PDOStatement::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOStatement::execute方法的具体用法?PHP PDOStatement::execute怎么用?PHP PDOStatement::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOStatement
的用法示例。
在下文中一共展示了PDOStatement::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rewind
function rewind()
{
$this->PDOStatement = $this->pdo->prepare($this->sql . ' ' . $this->ordersql . ' ' . $this->limitsql);
$this->PDOStatement->execute($this->params);
$this->PDOStatement->setFetchMode(PDO::FETCH_ASSOC);
$this->position = 0;
}
示例2: init
public function init()
{
$selectQuery = $this->dbHandler->createSelectQuery();
$selectQuery->select('filepath')->from($this->dbHandler->quoteTable('ezimagefile'));
$this->statement = $selectQuery->prepare();
$this->statement->execute();
}
示例3: execute
/**
* @param array|null $parameters
* @param bool|null $disableQueryBuffering
* @throws CM_Db_Exception
* @return CM_Db_Result
*/
public function execute(array $parameters = null, $disableQueryBuffering = null)
{
$disableQueryBuffering = (bool) $disableQueryBuffering;
$retryCount = 1;
for ($try = 0; true; $try++) {
try {
if ($disableQueryBuffering) {
$this->_client->setBuffered(false);
}
@$this->_pdoStatement->execute($parameters);
if ($disableQueryBuffering) {
$this->_client->setBuffered(true);
}
CM_Service_Manager::getInstance()->getDebug()->incStats('mysql', $this->getQueryString());
return new CM_Db_Result($this->_pdoStatement);
} catch (PDOException $e) {
if ($try < $retryCount && $this->_client->isConnectionLossError($e)) {
$this->_client->disconnect();
$this->_client->connect();
$this->_reCreatePdoStatement();
continue;
}
throw new CM_Db_Exception('Cannot execute SQL statement', null, ['tries' => $try, 'originalExceptionMessage' => $e->getMessage(), 'query' => $this->_pdoStatement->queryString]);
}
}
throw new CM_Db_Exception('Line should never be reached');
}
示例4: execute
/**
* @see \PDOStatement::execute
*/
public function execute(array $input_parameters = array())
{
$start = microtime(true);
$result = $this->statement->execute($input_parameters);
$this->pdo->addLog(array('query' => $this->statement->queryString, 'time' => microtime(true) - $start, 'values' => array_merge($this->binds, $input_parameters)));
return $result;
}
示例5: __construct
public function __construct(Connection $connection, $queryString, array $params)
{
$time = microtime(TRUE);
$this->connection = $connection;
$this->supplementalDriver = $connection->getSupplementalDriver();
$this->queryString = $queryString;
$this->params = $params;
try {
if (substr($queryString, 0, 2) === '::') {
$connection->getPdo()->{substr($queryString, 2)}();
} elseif ($queryString !== NULL) {
static $types = ['boolean' => PDO::PARAM_BOOL, 'integer' => PDO::PARAM_INT, 'resource' => PDO::PARAM_LOB, 'NULL' => PDO::PARAM_NULL];
$this->pdoStatement = $connection->getPdo()->prepare($queryString);
foreach ($params as $key => $value) {
$type = gettype($value);
$this->pdoStatement->bindValue(is_int($key) ? $key + 1 : $key, $value, isset($types[$type]) ? $types[$type] : PDO::PARAM_STR);
}
$this->pdoStatement->setFetchMode(PDO::FETCH_ASSOC);
$this->pdoStatement->execute();
}
} catch (\PDOException $e) {
$e = $this->supplementalDriver->convertException($e);
$e->queryString = $queryString;
throw $e;
}
$this->time = microtime(TRUE) - $time;
}
示例6: findAll
/**
* <b>Não é passado com os Joins</b>
*
* @return array[Objetos]
*/
public function findAll()
{
$sql = "SELECT * FROM {$this->Table}";
$this->Stmt = Conn::prepare($sql);
$this->Stmt->execute();
return $this->Stmt->fetchAll();
}
示例7: execute
/**
* @return bool
*
* @todo probably we can unset query an params to free up memory
*/
protected function execute()
{
$this->statement = $this->dbh->prepare($this->query);
// set fetchMode to assoc, it is easier to copy data from an array than an object
$this->statement->setFetchMode(PDO::FETCH_ASSOC);
return $this->statement->execute($this->params);
}
示例8: execute
/**
* @see \Nanozen\Contracts\Providers\Database\DatabaseProviderContract::execute()
* @return boolean
*/
public function execute(array $parameters = [])
{
if (is_null($this->query)) {
throw new \Exception('Cannot invoke execute. Try using query or prepare/execute before fetch.');
}
return $this->query->execute($parameters);
}
示例9: get_row
/**
* @param PDOStatement $stm
* @param array $data
* @return array
*/
protected function get_row(PDOStatement $stm, array $data = array())
{
$data ? $stm->execute($data) : $stm->execute();
$stm->setFetchMode(PDO::FETCH_ASSOC);
$var = $stm->fetch();
return $var;
}
示例10: _refresh
/**
* Reexecutes recordset query with the same parameters
* This function is called inside @see rewind()
*
*/
protected function _refresh()
{
$this->_statement->execute($this->_params);
if ($this->_statement->errorCode() !== '00000') {
throw new DbException($this->_statement->errorInfo(), $this->_statement->queryString);
}
$this->_currentRowIndex = 0;
}
示例11: execute
/**
* Executes a SQL statement
*
* @param string $sql
* @param array $parameters
* @param \PDO $connection
* @param int $fetchMode
*
* @return int The number of affected rows
*/
public static function execute($sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC)
{
static::$_statement = static::createStatement($sql, $connection, $fetchMode);
if (empty($parameters)) {
return static::$_statement->execute();
}
return static::$_statement->execute($parameters);
}
示例12: writeProduct
/**
* @param \Generated\Shared\Transfer\ProductConcreteTransfer $productConcreteTransfer
*
* @return bool
*/
public function writeProduct(ProductConcreteTransfer $productConcreteTransfer)
{
$this->productStatement->execute([':sku' => $productConcreteTransfer->getSku(), ':isActive' => (int) $productConcreteTransfer->getIsActive(), ':attributes' => json_encode($productConcreteTransfer->getAttributes()), ':productAbstractSku' => $productConcreteTransfer->getProductAbstractSku()]);
foreach ($productConcreteTransfer->getLocalizedAttributes() as $localizedAttributes) {
$this->attributesStatement->execute([':productSku' => $productConcreteTransfer->getSku(), ':name' => $localizedAttributes->getName(), ':attributes' => json_encode($localizedAttributes->getAttributes()), ':fkLocale' => $this->localeTransfer->getIdLocale()]);
}
return true;
}
示例13: execute
/**
* Execute the statement
*/
public function execute()
{
$start = microtime(true);
$result = $this->statement->execute();
$time = microtime(true) - $start;
DB::dbh()->log($this->postBindingStatement, round($time * 1000, 3));
return $result;
}
示例14: execute
/**
* {@inheritdoc}
*/
public function execute($input_parameters = null)
{
$parameters = null === $input_parameters ? $this->binds : $input_parameters;
$this->profiler->startQuery($this->statement->queryString, $parameters);
$result = $this->statement->execute($input_parameters);
$this->profiler->stopQuery();
return $result;
}
示例15: execute
public function execute($params = [])
{
if ($params) {
$this->params = $params;
}
$this->stmt->execute($this->params);
return $this;
}