當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::exec方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:10,代碼來源:DBALPurger.php

示例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());
 }
開發者ID:comphppuebla,項目名稱:echale-gas-api,代碼行數:7,代碼來源:GasStationsCest.php

示例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']);
 }
開發者ID:dongww,項目名稱:simple-db,代碼行數:8,代碼來源:ManagerFactoryTest.php

示例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']);
     }
 }
開發者ID:kutny,項目名稱:fixtures-bundle,代碼行數:9,代碼來源:FixturesWithSampleDataApplierCommand.php

示例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)");
 }
開發者ID:Combustible,項目名稱:core,代碼行數:10,代碼來源:sqlitemigration.php

示例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);
     }
 }
開發者ID:nlescure,項目名稱:ezpublish-kernel,代碼行數:10,代碼來源:DbBasedInstaller.php

示例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'))");
 }
開發者ID:Combustible,項目名稱:core,代碼行數:10,代碼來源:mysqlmigration.php

示例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);
 }
開發者ID:shopwareLabs,項目名稱:SwagImportExport,代碼行數:15,代碼來源:CategoryWriter.php

示例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);
    }
開發者ID:Basster,項目名稱:hs-bremen-web-api,代碼行數:11,代碼來源:OrderRepository.php

示例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();
 }
開發者ID:olucao,項目名稱:owncloud-core,代碼行數:11,代碼來源:repairinnodb.php

示例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);
 }
開發者ID:olucao,項目名稱:owncloud-core,代碼行數:12,代碼來源:repaircollation.php

示例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);
 }
開發者ID:kenwi,項目名稱:core,代碼行數:13,代碼來源:repairsqliteautoincrement.php

示例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()]);
         }
     }
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:18,代碼來源:PluginCategoryService.php

示例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;
 }
開發者ID:JackPrice,項目名稱:phpq,代碼行數:34,代碼來源:DoctrineDBALDriver.php


注:本文中的Doctrine\DBAL\Connection::exec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。