本文整理匯總了PHP中Illuminate\Database\Connection::setQueryGrammar方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::setQueryGrammar方法的具體用法?PHP Connection::setQueryGrammar怎麽用?PHP Connection::setQueryGrammar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::setQueryGrammar方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getConnection
/**
* Returns the database connection.
*
* @return \Illuminate\Database\Connection
* @throws \InvalidArgumentException
*/
public function getConnection()
{
if ($this->connection === null) {
$this->connection = new Connection($this->pdo, '', $this->tablePrefix);
// We will now provide the query grammar to the connection.
switch ($this->driverName) {
case 'mysql':
$queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\MySqlGrammar';
break;
case 'pgsql':
$queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\PostgresGrammar';
break;
case 'sqlsrv':
$queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\SqlServerGrammar';
break;
case 'sqlite':
$queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\SQLiteGrammar';
break;
default:
throw new \InvalidArgumentException("Cannot determine grammar to use based on {$this->driverName}.");
break;
}
$this->connection->setQueryGrammar(new $queryGrammar());
}
return $this->connection;
}