本文整理汇总了PHP中Illuminate\Database\Connection::statement方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::statement方法的具体用法?PHP Connection::statement怎么用?PHP Connection::statement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::statement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drop
/**
* function to safely drop trigger db object
*
* @param string $name
* @return boolean
*/
public function drop($name)
{
if (!$name) {
return false;
}
return $this->connection->statement("\n declare\n e exception;\n pragma exception_init(e,-4080);\n begin\n execute immediate 'drop trigger {$name}';\n exception\n when e then\n null;\n end;");
}
示例2: drop
/**
* function to safely drop sequence db object
*
* @param string $name
* @return boolean
*/
public function drop($name)
{
// check if a valid name and sequence exists
if (!$name or !$this->exists($name)) {
return false;
}
return $this->connection->statement("\n declare\n e exception;\n pragma exception_init(e,-02289);\n begin\n execute immediate 'drop sequence {$name}';\n exception\n when e then\n null;\n end;");
}
示例3: truncate
/**
* Run a truncate statement on the table.
*
* @return void
*/
public function truncate()
{
foreach ($this->grammar->compileTruncate($this) as $sql => $bindings) {
$this->connection->statement($sql, $bindings);
}
}
示例4: disableForeignKeyConstraints
/**
* Disable foreign key constraints.
*
* @return bool
*/
public function disableForeignKeyConstraints()
{
return $this->connection->statement($this->grammar->compileDisableForeignKeyConstraints());
}
示例5: build
/**
* Execute the statements against the database.
*
* @param array $statements
* @return void
*/
protected function build($statements)
{
foreach ($statements as $statement) {
$this->connection->statement($statement);
}
}
示例6: commentColumn
/**
* Run the comment on column statement
*
* @param string $table
* @param string $column
* @param string $comment
*/
private function commentColumn($table, $column, $comment)
{
$table = $this->wrapValue($table);
$column = $this->wrapValue($column);
$this->connection->statement("comment on column {$table}.{$column} is '{$comment}'");
}
示例7: revokePrivileges
/**
* @param Connection $db
* @param array $creds
* @param string $fromServer
*
* @return bool
*/
protected function revokePrivileges($db, $creds, $fromServer)
{
return $db->transaction(function () use($db, $creds, $fromServer) {
// Create users
$_users = $this->getDatabaseUsers($creds, $fromServer);
try {
foreach ($_users as $_user) {
// Grants for instance database
if (!($_result = $db->statement('REVOKE ALL PRIVILEGES ON ' . $creds['database'] . '.* FROM ' . $_user))) {
$this->error('[provisioning:database] error revoking privileges from "' . $_user . '"');
continue;
}
$this->debug('[provisioning:database] grants revoked - complete');
if (!($_result = $db->statement('DROP USER ' . $_user))) {
$this->error('[provisioning:database] error dropping user "' . $_user . '"');
}
$_result && $this->debug('[provisioning:database] users dropped > ', $_users);
}
return true;
} catch (\Exception $_ex) {
$this->error('[provisioning:database] revoke grants - failure: ' . $_ex->getMessage());
return false;
}
});
}
示例8: configurePragma
/**
* @param \Illuminate\Database\Connection $db
*/
protected function configurePragma(Connection $db)
{
if ($this->configuration['driver'] !== 'sqlite') {
return;
}
// Enable foreign keys for the current connection/file
$db->statement('PRAGMA foreign_keys = ON;');
// Create sqlite-journal in memory only (instead of creating disk files)
$db->statement('PRAGMA journal_mode = MEMORY;');
// Do not wait for OS after sending write commands
$db->statement('PRAGMA synchronous = OFF;');
}
示例9: build
/**
* Execute the blueprint against the database.
*
* @param Illuminate\Database\Connection $connection
* @param Illuminate\Database\Schema\Grammars\Grammar $grammar
* @return void
*/
public function build(Connection $connection, Grammar $grammar)
{
foreach ($this->toSql($grammar) as $statement) {
$connection->statement($statement);
}
}