本文整理汇总了PHP中Zend_Db_Adapter_Pdo_Abstract::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Pdo_Abstract::query方法的具体用法?PHP Zend_Db_Adapter_Pdo_Abstract::query怎么用?PHP Zend_Db_Adapter_Pdo_Abstract::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Adapter_Pdo_Abstract
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Pdo_Abstract::query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFieldNamesAreLowercase
function testFieldNamesAreLowercase()
{
$result = $this->_db->query('SELECT * FROM ' . self::TableName . ' WHERE date_created > :placeholder', array('placeholder' => '2006-01-01'));
// use the PDOStatement $result to fetch all rows as an array
$row = $result->fetch();
$this->assertEquals(5, count($row));
// correct number of fields
$this->assertEquals('1', $row['id']);
// correct data
$this->assertTrue(array_key_exists('subtitle', $row));
// "subTitle" is now "subtitle"
$this->assertFalse(array_key_exists('subTitle', $row));
// "subTitle" is not a key
}
示例2: query
/**
* Execute a SQL statement and return the result
*
* Use $params to use a prepared statement.
*
* @param string $statement The statement to execute
* @param array $params The params to bind
*
* @return mixed
*/
public function query($statement, $params = array())
{
if ($this->zendConn !== null) {
return $this->zendConn->query($statement, $params);
}
if (empty($params)) {
return $this->pdoConn->query($statement);
}
$stmt = $this->pdoConn->prepare($statement);
$stmt->execute($params);
return $stmt;
}