本文整理汇总了PHP中Zend\Db\Adapter\Profiler\ProfilerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ProfilerInterface类的具体用法?PHP ProfilerInterface怎么用?PHP ProfilerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProfilerInterface类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute
*
* @param ParameterContainer|null $parameters
* @throws Exception\InvalidQueryException
* @return Result
*/
public function execute($parameters = null)
{
if (!$this->isPrepared()) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$parameters = $this->parameterContainer->getPositionalArray();
}
/** END Standard ParameterContainer Merging Block */
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
$resultResource = pg_execute($this->pgsql, $this->statementName, (array) $parameters);
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($resultResource === false) {
throw new Exception\InvalidQueryException(pg_last_error());
}
$result = $this->driver->createResult($resultResource);
return $result;
}
示例2: execute
/**
* Execute
*
* @param string $sql
* @throws Exception\RuntimeException
* @return mixed
*/
public function execute($sql)
{
if (!$this->isConnected()) {
$this->connect();
}
if (!$this->driver instanceof Sqlsrv) {
throw new Exception\RuntimeException('Connection is missing an instance of Sqlsrv');
}
if ($this->profiler) {
$this->profiler->profilerStart($sql);
}
$returnValue = sqlsrv_query($this->resource, $sql);
if ($this->profiler) {
$this->profiler->profilerFinish($sql);
}
// if the returnValue is something other than a Sqlsrv_result, bypass wrapping it
if ($returnValue === false) {
$errors = sqlsrv_errors();
// ignore general warnings
if ($errors[0]['SQLSTATE'] != '01000') {
throw new Exception\RuntimeException('An exception occurred while trying to execute the provided $sql', null, new ErrorException($errors));
}
}
$result = $this->driver->createResult($returnValue);
return $result;
}
示例3: execute
/**
* Execute
*
* @param null $parameters
* @return Result
*/
public function execute($parameters = null)
{
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
/** END Standard ParameterContainer Merging Block */
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
set_error_handler(function () {
}, E_WARNING);
// suppress warnings
$response = db2_execute($this->resource, $this->parameterContainer->getPositionalArray());
restore_error_handler();
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($response === false) {
throw new Exception\RuntimeException(db2_stmt_errormsg($this->resource));
}
$result = $this->driver->createResult($this->resource);
return $result;
}
示例4: execute
/**
* @param string $sql
* @throws Exception\InvalidQueryException
* @return resource|\Zend\Db\ResultSet\ResultSetInterface
*/
public function execute($sql)
{
if (!$this->isConnected()) {
$this->connect();
}
if ($this->profiler) {
$this->profiler->profilerStart($sql);
}
$resultResource = pg_query($this->resource, $sql);
if ($this->profiler) {
$this->profiler->profilerFinish($sql);
}
// if the returnValue is something other than a pg result resource, bypass wrapping it
if ($resultResource === false) {
throw new Exception\InvalidQueryException(pg_errormessage());
}
$resultPrototype = $this->driver->createResult($resultResource === true ? $this->resource : $resultResource);
return $resultPrototype;
}
示例5: execute
/**
* Execute
*
* @param ParameterContainer $parameters
* @throws Exception\RuntimeException
* @return mixed
*/
public function execute($parameters = null)
{
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
/** END Standard ParameterContainer Merging Block */
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
$return = $this->resource->execute();
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($return === false) {
throw new Exception\RuntimeException($this->resource->error);
}
if ($this->bufferResults === true) {
$this->resource->store_result();
$this->isPrepared = false;
$buffered = true;
} else {
$buffered = false;
}
$result = $this->driver->createResult($this->resource, $buffered);
return $result;
}
示例6: find
/**
* @param array $fields
* @param array $orders
* @param null|int $limit
* @param null|int $offset
*
* @return ResultSet|ResultSetInterface
* @throws RuntimeException
* @throws \Exception
*/
public function find($fields = [], $orders = [], $limit = null, $offset = null)
{
if (!is_array($fields) || !is_array($orders)) {
throw new \Exception("Wrong input type of parameters !");
}
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
// apply preSelect features
// $this -> featureSet -> apply( 'preSelect', array( $select ) );
$return = $this->collection->find($this->_where($fields));
foreach ($orders as $_k => $_v) {
if (strtolower($_v) == 'desc' || $_v < 0) {
$orders[$_k] = -1;
} else {
$orders[$_k] = 1;
}
}
if (!empty($orders)) {
$return->sort($this->_orders($orders));
}
if ($limit !== null) {
$return->limit($limit);
}
if ($offset !== null) {
$return->skip($offset);
}
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($return === false) {
throw new RuntimeException($this->getDriver()->getConnection()->getDB()->lastError());
}
$result = $this->adapter->getDriver()->createResult($return, $this->getTable());
$resultSet = clone $this->resultSetPrototype;
$resultSet->initialize($result);
// apply postSelect features
// $this -> featureSet -> apply( 'postSelect', array( $result, $resultSet ) );
return $resultSet;
}
示例7: execute
/**
* Execute
*
* @param ParameterContainer $parameters
* @return mixed
*/
public function execute($parameters = null)
{
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
/** END Standard ParameterContainer Merging Block */
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
if ($this->driver->getConnection()->inTransaction()) {
$ret = @oci_execute($this->resource, OCI_NO_AUTO_COMMIT);
} else {
$ret = @oci_execute($this->resource, OCI_COMMIT_ON_SUCCESS);
}
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($ret === false) {
$e = oci_error($this->resource);
throw new Exception\RuntimeException($e['message'], $e['code']);
}
$result = $this->driver->createResult($this->resource);
return $result;
}
示例8: execute
/**
* Execute
*
* @param string $sql
* @return Result
*/
public function execute($sql)
{
if (!$this->isConnected()) {
$this->connect();
}
if ($this->profiler) {
$this->profiler->profilerStart($sql);
}
set_error_handler(function () {
}, E_WARNING);
// suppress warnings
$resultResource = db2_exec($this->resource, $sql);
restore_error_handler();
if ($this->profiler) {
$this->profiler->profilerFinish($sql);
}
// if the returnValue is something other than a pg result resource, bypass wrapping it
if ($resultResource === false) {
throw new Exception\InvalidQueryException(db2_stmt_errormsg());
}
return $this->driver->createResult($resultResource === true ? $this->resource : $resultResource);
}
示例9: execute
/**
* @param null|array|ParameterContainer $parameters
* @throws Exception\InvalidQueryException
* @return Result
*/
public function execute($parameters = null)
{
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
/** END Standard ParameterContainer Merging Block */
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
try {
// var_dump($this->resource);
$this->resource->execute();
} catch (\PDOException $e) {
if ($this->profiler) {
$this->profiler->profilerFinish();
}
throw new Exception\InvalidQueryException('Statement could not be executed (' . implode(' - ', $this->resource->errorInfo()) . ')', null, $e);
}
if ($this->profiler) {
$this->profiler->profilerFinish();
}
$result = $this->driver->createResult($this->resource, $this);
return $result;
}
示例10: execute
/**
* Execute
*
* @param array|ParameterContainer $parameters
* @throws Exception\RuntimeException
* @return Result
*/
public function execute($parameters = null)
{
/** END Standard ParameterContainer Merging Block */
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
$resultValue = sqlsrv_execute($this->resource);
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($resultValue === false) {
$errors = sqlsrv_errors();
// ignore general warnings
if ($errors[0]['SQLSTATE'] != '01000') {
throw new Exception\RuntimeException($errors[0]['message']);
}
}
$result = $this->driver->createResult($this->resource);
return $result;
}
示例11: execute
/**
* Execute
*
* @param string $sql
* @throws Exception\InvalidQueryException
* @return Result
*/
public function execute($sql)
{
if (!$this->isConnected()) {
$this->connect();
}
try {
if ($this->profiler) {
$this->profiler->profilerStart($sql);
}
$resultResource = $this->db->execute($sql);
if ($this->profiler) {
$this->profiler->profilerFinish($sql);
}
// if the returnValue is something other than a mysqli_result, bypass wrapping it
if (!$resultResource['ok']) {
throw new Exception\InvalidQueryException($resultResource['errmsg']);
}
} catch (\Exception $e) {
throw new Exception\InvalidQueryException($ex->getMessage(), $ex->getCode());
}
$resultPrototype = $this->driver->createResult($resultResource === true ? $this->resource : $resultResource);
return $resultResource['retval'];
}
示例12: execute
/**
* Execute
*
* @param null|array|ParameterContainer $parameters
* @throws Exception\RuntimeException
* @return mixed
*/
public function execute($parameters = null)
{
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
/** END Standard ParameterContainer Merging Block */
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
$args = $this->parameterContainer->getPositionalArray();
$argArray = [$this->resource];
if (!empty($args)) {
$argArray = array_merge($argArray, $args);
}
//die(var_dump($argArray));
$response = call_user_func_array('ibase_execute', $argArray);
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($response === false) {
throw new Exception\RuntimeException(ibase_errmsg());
}
$result = $this->driver->createResult($response);
return $result;
}
示例13: execute
/**
* Execute
*
* @param ParameterContainer|array $parameters
* @throws Exception\RuntimeException
* @return mixed
*/
public function execute($parameters = null)
{
if (!$this->isPrepared) {
$this->prepare();
}
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
/** END Standard ParameterContainer Merging Block */
if ($this->profiler) {
$this->profiler->profilerStart($this);
}
if ($this->bufferResults === true) {
// $this -> resource -> store_result();
// $this -> isPrepared = false;
$buffered = true;
} else {
$buffered = false;
}
if ($this->sql instanceof \MongoZend\Db\NoSql\Select) {
$_order = $this->sql->getOrder();
// , $this -> sql->getColumns()
$return = $this->resource->find($this->sql->getWhere());
if (!empty($_order)) {
foreach ($_order as $_k => $_v) {
if (strtolower($_v) == 'desc' || $_v < 0) {
$_order[$_k] = -1;
} else {
$_order[$_k] = 1;
}
}
$return = $return->sort($_order);
}
if ($this->sql->getLimit() !== null) {
$return = $return->limit($this->sql->getLimit());
}
if ($this->sql->getOffset() !== null) {
$return = $return->skip($this->sql->getOffset());
}
} elseif ($this->sql instanceof \MongoZend\Db\NoSql\Insert) {
$_data = $this->sql->getValues();
$return = $this->resource->insert($_data);
$buffered = $this->sql->getRawState()['table'];
$this->driver->getConnection()->storeLastGeneratedValue($buffered, $_data['_id']);
// $return = $this -> resource -> update( [ '_id' => $_data[ '_id' ] ], [ '$set' => array( "id" => (string) $_data[ '_id' ] ) ] );
} elseif ($this->sql instanceof \MongoZend\Db\NoSql\Update) {
$_data = $this->sql->getSet();
$_where = $this->sql->getWhere();
$return = $this->resource->update($_where, $_data);
$buffered = $this->sql->getRawState()['table'];
$this->driver->getConnection()->storeLastGeneratedValue($buffered, $_data['_id']);
} elseif ($this->sql instanceof \MongoZend\Db\NoSql\Delete) {
$_where = $this->sql->getWhere();
$return = $this->resource->remove($_where);
$buffered = $this->sql->getRawState()['table'];
$this->driver->getConnection()->storeLastGeneratedValue($buffered, null);
} else {
$return = $this->resource->execute();
}
if ($this->profiler) {
$this->profiler->profilerFinish();
}
if ($return === false) {
throw new Exception\RuntimeException($this->getDriver()->getConnection()->getDB()->lastError());
}
$result = $this->driver->createResult($return, $buffered);
return $result;
}
示例14: stopQuery
/**
* {@inheritdoc}
*/
public function stopQuery()
{
$this->profiler->profilerFinish();
}