本文整理汇总了PHP中Doctrine\DBAL\Connection::errorInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::errorInfo方法的具体用法?PHP Connection::errorInfo怎么用?PHP Connection::errorInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::errorInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connectDatabase
private function connectDatabase(OutputInterface $output)
{
$param = array();
$param['host'] = $this->dialog->ask($output, '<question>Where is your database server? [localhost]</question> ', 'localhost');
$param['user'] = $this->dialog->ask($output, '<question>What is your database username? [root]</question> ', 'root');
$param['password'] = $this->dialog->ask($output, '<question>What is your database password?</question> ', '');
$param['driver'] = 'pdo_mysql';
// Save dbName for later use to create database
$this->dbName = $this->dialog->ask($output, '<question>What is your database name? [BungaWire]</question> ', 'BungaWire');
$output->writeln('');
// Write empty line for easy read
$config = new Configuration();
$this->dbConnection = DriverManager::getConnection($param, $config);
$this->dbConnection->connect();
if ($this->dbConnection->isConnected() === false) {
$output->writeln('Database connection failed, please check your setting');
$output->writeln('You connection configuration is:');
$output->writeln('host: ' . $param['host']);
$output->writeln('user: ' . $param['user']);
$output->writeln('password: ' . $param['password']);
$output->writeln('Database Name: ' . $param['dbname']);
$output->writeln('Driver: ' . $param['driver']);
$output->writeln($this->dbConnection->errorInfo());
$output->writeln('Please try again!');
$this->connectDatabase($output);
} else {
$output->writeln('Database connected!');
}
}
示例2: __get
/**
* Return an object property
*
* @param string $strKey The property name
*
* @return string|null The property value
*/
public function __get($strKey)
{
if ($strKey == 'error') {
$info = $this->resConnection->errorInfo();
return 'SQLSTATE ' . $info[0] . ': error ' . $info[1] . ': ' . $info[2];
}
return null;
}
示例3: errorMsg
/**
* Fetch extended error information associated with the last database operation.
*
* @return string
*/
public function errorMsg()
{
return json_encode($this->connection->errorInfo());
}