本文整理汇总了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;
}