本文整理匯總了PHP中Doctrine_Connection::getAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Connection::getAttribute方法的具體用法?PHP Doctrine_Connection::getAttribute怎麽用?PHP Doctrine_Connection::getAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine_Connection
的用法示例。
在下文中一共展示了Doctrine_Connection::getAttribute方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* execute
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null)
{
try {
$event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
$this->_conn->getListener()->preStmtExecute($event);
$result = true;
if (!$event->skipOperation) {
if ($this->_conn->getAttribute(Doctrine::PORTABILITY_EMPTY_TO_NULL)) {
foreach ($params as $key => $value) {
if ($value == '') {
$params[$key] = null;
}
}
}
$result = $this->_stmt->execute($params);
$this->_conn->incrementQueryCount();
}
$this->_conn->getListener()->postStmtExecute($event);
return $result;
} catch (PDOException $e) {
} catch (Doctrine_Adapter_Exception $e) {
}
$this->_conn->rethrowException($e, $this);
return false;
}
示例2: enumIndex
/**
* Retrieves an enum index.
* @see enumValue()
*
* @param string $fieldName
* @param mixed $value value of the enum considered
* @return integer can be string if native enums are used.
*/
public function enumIndex($fieldName, $value)
{
$values = $this->getEnumValues($fieldName);
if ($this->_conn->getAttribute(Doctrine_Core::ATTR_USE_NATIVE_ENUM)) {
return $value;
}
return array_search($value, $values);
}
示例3: _execute
public function _execute($params)
{
$params = $this->_conn->convertBooleans(array_merge($this->_params, $params));
if (!$this->_view) {
$query = $this->getQuery($params);
} else {
$query = $this->_view->getSelectSql();
}
$params = $this->convertEnums($params);
if ($this->isLimitSubqueryUsed() && $this->_conn->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') {
$params = array_merge($params, $params);
}
if ($this->type !== self::SELECT) {
return $this->_conn->exec($query, $params);
}
$stmt = $this->_conn->execute($query, $params);
return $stmt;
}
示例4: execute
/**
* execute
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null)
{
try {
$event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
$this->_conn->getListener()->preStmtExecute($event);
$result = true;
if (!$event->skipOperation) {
if ($this->_conn->getAttribute(Doctrine_Core::ATTR_PORTABILITY) & Doctrine_Core::PORTABILITY_EMPTY_TO_NULL) {
foreach ($params as $key => $value) {
if ($value === '') {
$params[$key] = null;
}
}
}
if ($params) {
$pos = 0;
foreach ($params as $key => $value) {
$pos++;
$param = is_numeric($key) ? $pos : $key;
if (is_resource($value)) {
$this->_stmt->bindParam($param, $params[$key], Doctrine_Core::PARAM_LOB);
} else {
$this->_stmt->bindParam($param, $params[$key]);
}
}
}
$result = $this->_stmt->execute();
$this->_conn->incrementQueryCount();
}
$this->_conn->getListener()->postStmtExecute($event);
//fix a possible "ORA-01000: maximum open cursors exceeded" when many non-SELECTs are executed and the profiling is enabled
if ('Oracle' == $this->getConnection()->getDriverName()) {
$queryBeginningSubstring = strtoupper(substr(ltrim($this->_stmt->queryString), 0, 6));
if ($queryBeginningSubstring != 'SELECT' && substr($queryBeginningSubstring, 0, 4) != 'WITH') {
$this->closeCursor();
}
}
return $result;
} catch (PDOException $e) {
} catch (Doctrine_Adapter_Exception $e) {
}
$this->_conn->rethrowException($e, $this);
return false;
}
示例5: execute
/**
* execute
* Executes a prepared statement
*
* If the prepared statement included parameter markers, you must either:
* call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
* bound variables pass their value as input and receive the output value,
* if any, of their associated parameter markers or pass an array of input-only
* parameter values
*
*
* @param array $params An array of values with as many elements as there are
* bound parameters in the SQL statement being executed.
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function execute($params = null)
{
try {
$event = new Doctrine_Event($this, Doctrine_Event::STMT_EXECUTE, $this->getQuery(), $params);
$this->_conn->getListener()->preStmtExecute($event);
$result = true;
if (!$event->skipOperation) {
if ($this->_conn->getAttribute(Doctrine_Core::ATTR_PORTABILITY) & Doctrine_Core::PORTABILITY_EMPTY_TO_NULL) {
foreach ($params as $key => $value) {
if ($value === '') {
$params[$key] = null;
}
}
}
if ($params) {
$pos = 0;
foreach ($params as $key => $value) {
if ($value === null) {
continue;
}
$pos++;
$param = is_numeric($key) ? $pos : $key;
if (is_resource($value)) {
$this->_stmt->bindParam($param, $params[$key], Doctrine_Core::PARAM_LOB);
} else {
$this->_stmt->bindParam($param, $params[$key]);
}
}
}
$result = $this->_stmt->execute();
$this->_conn->incrementQueryCount();
}
$this->_conn->getListener()->postStmtExecute($event);
return $result;
} catch (PDOException $e) {
} catch (Doctrine_Adapter_Exception $e) {
}
$this->_conn->rethrowException($e, $this);
return false;
}
示例6: getConnectionAsString
/**
* Generates a string representation of a connection.
*
* This method returns an html dump of a connection, containing state, open
* transactions and loaded tables.
*
* @param Doctrine_Connection $connection
* @return string
*/
public static function getConnectionAsString(Doctrine_Connection $connection)
{
$r[] = '<pre>';
$r[] = 'Doctrine_Connection object';
$r[] = 'State : ' . Doctrine_Lib::getConnectionStateAsString($connection->transaction->getState());
$r[] = 'Open Transactions : ' . $connection->transaction->getTransactionLevel();
$r[] = 'Table in memory : ' . $connection->count();
$r[] = 'Driver name : ' . $connection->getAttribute(Doctrine::ATTR_DRIVER_NAME);
$r[] = "</pre>";
return implode("\n", $r) . "<br>";
}