本文整理匯總了PHP中Magento\Framework\DB\Adapter\Pdo\Mysql::query方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mysql::query方法的具體用法?PHP Mysql::query怎麽用?PHP Mysql::query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\DB\Adapter\Pdo\Mysql
的用法示例。
在下文中一共展示了Mysql::query方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testMultipleQueryException
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Cannot execute multiple queries
*/
public function testMultipleQueryException()
{
$sql = "SELECT COUNT(*) AS _num FROM test; ";
$sql .= "INSERT INTO test(id) VALUES (1); ";
$sql .= "SELECT COUNT(*) AS _num FROM test; ";
$this->_mockAdapter->query($sql);
}
示例2: testCheckDdlTransaction
/**
* Test DDL query inside transaction in Developer mode
*
* @dataProvider ddlSqlQueryProvider
* @expectedException \Exception
* @expectedExceptionMessage DDL statements are not allowed in transactions
*/
public function testCheckDdlTransaction($ddlQuery)
{
$this->_mockAdapter->query($ddlQuery);
}
示例3: runCommand
/**
* Run sql code
*
* @param string $command
* @return $this
*/
public function runCommand($command)
{
$this->_write->query($command);
return $this;
}
示例4: query
/**
* @param string|\Zend_Db_Select $sql
* @param array $bind
* @return void|\Zend_Db_Statement_Pdo
*/
public function query($sql, $bind = [])
{
if ($this->verbosity >= OutputInterface::VERBOSITY_VERBOSE && false === strpos($sql, 'SHOW ') && false === strpos($sql, 'DESCRIBE ')) {
$this->output->writeln('SQL: <info>' . $sql . '</info>');
}
$ret = null;
try {
$ret = parent::query($sql, $bind);
} catch (\Exception $e) {
$this->output->writeln('Failed: <error>' . $e->getMessage() . '</error>' . PHP_EOL . '<info>' . $sql . '</info>');
}
return $ret;
}