本文整理匯總了PHP中Doctrine\DBAL\Connection::exec方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::exec方法的具體用法?PHP Connection::exec怎麽用?PHP Connection::exec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::exec方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: purge
/**
* {@inheritdoc}
*/
public function purge()
{
foreach ($this->tables as $table) {
$sql = 'DELETE FROM ' . $table;
$this->connection->exec($sql);
}
}
示例2: _before
public function _before()
{
$this->connection->exec('DELETE FROM stations');
$loader = new YamlLoader(__DIR__ . '/../../data/fixtures/stations.yml');
$persister = new ConnectionPersister($this->connection);
$persister->persist($loader->load());
}
示例3: testGetSqlStack
public function testGetSqlStack()
{
$sql = 'select * from user';
static::$conn->exec($sql);
$sqlStack = static::$mf->getSqlStack();
$this->assertCount(1, $sqlStack);
$this->assertEquals($sql, $sqlStack[1]['sql']);
}
示例4: backupDatabase
private function backupDatabase(Connection $connection, $newDatabaseName, $databaseName)
{
$connection->exec('CREATE DATABASE `' . $newDatabaseName . '` COLLATE `utf8_general_ci`');
$statement = 'SELECT ' . 'concat("RENAME TABLE `' . $databaseName . '`.", table_name," TO `' . $newDatabaseName . '`.", table_name, ";") as query ' . 'FROM information_schema.TABLES WHERE table_schema= "' . $databaseName . '"';
$renameTableSql = $connection->fetchAll($statement);
foreach ($renameTableSql as $sql) {
$connection->exec($sql['query']);
}
}
示例5: setUp
public function setUp()
{
$this->connection = \OC_DB::getConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->markTestSkipped("Test only relevant on Sqlite");
}
$dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
$this->tableName = uniqid($dbPrefix . "_enum_bit_test");
$this->connection->exec("CREATE TABLE {$this->tableName}(t0 tinyint unsigned, t1 tinyint)");
}
示例6: runQueriesFromFile
protected function runQueriesFromFile($file)
{
$queries = array_filter(preg_split('(;\\s*$)m', file_get_contents($file)));
if (!$this->output->isQuiet()) {
$this->output->writeln(sprintf("Executing %d queries from %s on database %s", count($queries), $file, $this->db->getDatabase()));
}
foreach ($queries as $query) {
$this->db->exec($query);
}
}
示例7: setUp
public function setUp()
{
$this->connection = \OC_DB::getConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
}
$dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
$this->tableName = uniqid($dbPrefix . "_enum_bit_test");
$this->connection->exec("CREATE TABLE {$this->tableName}(b BIT, e ENUM('1','2','3','4'))");
}
示例8: write
/**
* @param string $articleId
* @param array $categories
* @throws DBALException
*/
public function write($articleId, $categories)
{
if (!$categories) {
return;
}
$values = $this->prepareValues($categories, $articleId);
$sql = "\n INSERT INTO s_articles_categories (articleID, categoryID)\n VALUES {$values}\n ON DUPLICATE KEY UPDATE categoryID=VALUES(categoryID), articleID=VALUES(articleID)\n ";
$this->connection->exec($sql);
$this->updateArticlesCategoriesRO($articleId);
}
示例9: createTable
public function createTable()
{
$sql = <<<EOS
CREATE TABLE IF NOT EXISTS `{$this->getTableName()}` (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
status VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
)
EOS;
return $this->connection->exec($sql);
}
示例10: setUp
public function setUp()
{
$this->connection = \OC_DB::getConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
}
$dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
$this->tableName = uniqid($dbPrefix . "_innodb_test");
$this->connection->exec("CREATE TABLE {$this->tableName}(id INT) ENGINE MyISAM");
$this->repair = new \OC\Repair\InnoDB();
}
示例11: setUp
public function setUp()
{
$this->connection = \OC_DB::getConnection();
$this->config = \OC::$server->getConfig();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
}
$dbPrefix = $this->config->getSystemValue("dbtableprefix");
$this->tableName = uniqid($dbPrefix . "_collation_test");
$this->connection->exec("CREATE TABLE {$this->tableName}(text VARCHAR(16)) COLLATE utf8_unicode_ci");
$this->repair = new TestCollationRepair($this->config, $this->connection);
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
$this->config = \OC::$server->getConfig();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->markTestSkipped("Test only relevant on Sqlite");
}
$dbPrefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
$this->tableName = $this->getUniqueID($dbPrefix . 'autoinc_test');
$this->connection->exec('CREATE TABLE ' . $this->tableName . '("someid" INTEGER NOT NULL, "text" VARCHAR(16), PRIMARY KEY("someid"))');
$this->repair = new \OC\Repair\SqliteAutoincrement($this->connection);
}
示例13: setUp
protected function setUp()
{
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
self::markTestSkipped('This test requires SQLite support in your environment');
}
$this->con = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]);
// import the schema
$schema = new Schema($this->getOptions());
foreach ($schema->toSql($this->con->getDatabasePlatform()) as $sql) {
$this->con->exec($sql);
}
$this->sid = UserSecurityIdentity::fromAccount(new User('jimmy', 'jimmypass'));
$this->aclProvider = $this->getProvider();
}
開發者ID:GlobalTradingTechnologies,項目名稱:reverse-search-acl,代碼行數:14,代碼來源:ReverseSearchAclProviderTest.php
示例14: synchronize
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function synchronize()
{
$categories = $this->pluginService->getCategories();
$this->connection->exec("DELETE FROM s_core_plugin_categories");
$statement = $this->connection->prepare("INSERT INTO s_core_plugin_categories (id, locale, parent_id, name)\n VALUES (:id, :locale, :parent_id, :name)");
$pseudo = $this->getPseudoCategories();
foreach ($pseudo as $category) {
$statement->execute($category);
}
foreach ($categories as $category) {
foreach ($category->getName() as $locale => $name) {
$statement->execute([':id' => $category->getId(), ':name' => $name, ':locale' => $locale, ':parent_id' => $category->getParentId()]);
}
}
}
示例15: performInitialSetup
/**
* @inheritdoc
*/
public function performInitialSetup()
{
$manager = $this->connection->getSchemaManager();
$from = $manager->createSchema();
$to = clone $from;
$table = $to->createTable($this->getQueueTableName());
$to->createSequence('job_seq');
$table->addColumn($this->columns[JobReflector::PROPERTY_ID], 'integer', ['autoincrement' => true]);
$table->addColumn($this->columns[JobReflector::PROPERTY_QUEUE], 'string');
$table->addColumn($this->columns[JobReflector::PROPERTY_CREATED], 'datetime');
$table->addColumn($this->columns[JobReflector::PROPERTY_SCHEDULE], 'datetime');
$table->addColumn($this->columns[JobReflector::PROPERTY_FAILED], 'boolean', ['notnull' => true, 'default' => false]);
$table->addColumn($this->columns[JobReflector::PROPERTY_FINISHED], 'datetime', ['notnull' => false, 'default' => null]);
$table->addColumn($this->columns[JobReflector::PROPERTY_RESULT], 'text', ['notnull' => false, 'default' => null]);
$table->addColumn($this->columns[JobReflector::PROPERTY_PROGRESS], 'decimal', ['notnull' => false, 'default' => null, 'precision' => 5, 'scale' => 2]);
$table->addColumn($this->columns[JobReflector::PROPERTY_LAST_ATTEMPT], 'datetime', ['notnull' => false, 'default' => null]);
$table->addColumn($this->columns[JobReflector::PROPERTY_TIMEOUT], 'datetime', ['notnull' => false, 'default' => null]);
$table->addColumn($this->columns[JobReflector::PROPERTY_RETRY_COUNT], 'integer');
$table->addColumn($this->columns[JobReflector::PROPERTY_RETRY], 'boolean', ['notnull' => true, 'default' => false]);
$table->addColumn($this->columns[JobReflector::PROPERTY_PARAMETERS], 'text', ['notnull' => false, 'default' => null]);
$table->addColumn($this->columns[JobReflector::PROPERTY_VERSION], 'integer');
$table->addColumn($this->columns['__CLASS__'], 'string');
$table->setPrimaryKey(array($this->columns[JobReflector::PROPERTY_ID]));
$sql = $from->getMigrateToSql($to, $this->connection->getDatabasePlatform());
$this->connection->beginTransaction();
foreach ($sql as $query) {
$this->connection->exec($query);
}
$this->connection->commit();
return;
}