当前位置: 首页>>代码示例>>PHP>>正文


PHP Schema::toSql方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Schema\Schema::toSql方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::toSql方法的具体用法?PHP Schema::toSql怎么用?PHP Schema::toSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Schema\Schema的用法示例。


在下文中一共展示了Schema::toSql方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createRepository

 public function createRepository(CategoryInterface $category)
 {
     $schema = new Schema();
     if ($this->isValid($category)) {
         /**
          * @var $category StandardSearchIndexerInterface
          */
         if (!$this->connection->tableExists($category->getIndexedSearchTable())) {
             $table = $schema->createTable($category->getIndexedSearchTable());
             $details = $category->getSearchIndexFieldDefinition();
             if (isset($details['columns'])) {
                 foreach ($details['columns'] as $column) {
                     $table->addColumn($column['name'], $column['type'], $column['options']);
                 }
             }
             if (isset($details['primary'])) {
                 $table->setPrimaryKey($details['primary']);
             }
             $queries = $schema->toSql($this->connection->getDatabasePlatform());
             foreach ($queries as $query) {
                 $this->connection->query($query);
             }
         }
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:25,代码来源:StandardSearchIndexer.php

示例2: assertSchemaSql

 protected function assertSchemaSql(Schema $schema, array $expectedSql)
 {
     $sql = $schema->toSql(new MySqlPlatform());
     foreach ($sql as &$el) {
         $el = str_replace(' DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB', '', $el);
     }
     $this->assertEquals($expectedSql, $sql);
 }
开发者ID:xamin123,项目名称:platform,代码行数:8,代码来源:ExtendSchemaTest.php

示例3: createTable

 /**
  * Creates task view model table in the database
  */
 public function createTable()
 {
     $schema = new Schema();
     $table = $schema->createTable($this->tableName);
     $table->addColumn('id', 'string', array('length' => 64, 'nullable' => false, 'unique' => true));
     $table->addColumn('content', 'string', array('length' => 255, 'nullable' => false));
     $table->setPrimaryKey(array('id'));
     foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
         $this->connection->exec($sql);
     }
 }
开发者ID:kinger-de,项目名称:symfony-cqrs-edition,代码行数:14,代码来源:TaskViewModelDoctrineDbalRepository.php

示例4: create

 public static function create()
 {
     $conn = ConnectionManager::getConnection();
     $schema = new DbSchema();
     $users = $schema->createTable("users");
     $users->addColumn("id", "integer", ["unsigned" => true]);
     $users->addColumn("username", "string", ["length" => 32]);
     $users->setPrimaryKey(["id"]);
     $users->addUniqueIndex(["username"]);
     foreach ($schema->toSql($conn->getDatabasePlatform()) as $query) {
         $conn->query($query);
     }
 }
开发者ID:avalonphp,项目名称:database,代码行数:13,代码来源:Schema.php

示例5: testCleanupForeignKeysDifferentOrder

 /**
  * @group DBAL-204
  */
 public function testCleanupForeignKeysDifferentOrder()
 {
     $config = new SchemaConfig();
     $config->setName("test");
     $schema = new Schema(array(), array(), $config);
     $testTable = $schema->createTable("test.test");
     $testTable->addColumn('id', 'integer');
     $fooTable = $schema->createTable("foo.bar");
     $fooTable->addColumn('id', 'integer');
     $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id"));
     $schema->visit(new RemoveNamespacedAssets());
     $sql = $schema->toSql(new MySqlPlatform());
     $this->assertEquals(1, count($sql), "Just one CREATE TABLE statement, no foreign key and table to foo.bar");
 }
开发者ID:Werelds,项目名称:FrameworkBenchmarks,代码行数:17,代码来源:RemoveNamespacedAssetsTest.php

示例6: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     global $app;
     /** @var EntityManager $em */
     $em = $app->make('em');
     MessagesSchema::create($schema = new Schema());
     // setup Doctrine DBAL
     $connection = $em->getConnection();
     $sql = $schema->toSql($connection->getDatabasePlatform());
     foreach ($sql as $query) {
         $connection->exec($query);
     }
     $this->info('Create Doctrine schema successfully.');
 }
开发者ID:trihtm,项目名称:annie-framework,代码行数:19,代码来源:CreateDoctrineSchemaCommand.php

示例7: executeChanges

 /**
  * Executes the changes.
  */
 public function executeChanges()
 {
     $platform = $this->db->getDatabasePlatform();
     if (!empty($this->dropTables)) {
         foreach ($this->dropTables as $t) {
             $this->sm->dropTable($this->prefix . $t);
         }
     }
     $sql = $this->schema->toSql($platform);
     if (!empty($sql)) {
         foreach ($sql as $s) {
             $this->db->executeUpdate($s);
         }
     }
     //reset schema
     $this->schema = new Schema([], [], $this->sm->createSchemaConfig());
     $this->dropTables = $this->addTables = [];
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:21,代码来源:TableSchemaHelper.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $schema = new Schema();
     $posts = $schema->createTable('posts');
     $posts->addColumn('id', Type::INTEGER);
     $posts->setPrimaryKey(['id']);
     $posts->addColumn('status', Type::STRING);
     $this->connection->exec('DROP TABLE IF EXISTS posts');
     foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
         $this->connection->exec($sql);
     }
     $i = 1;
     while ($i <= 10) {
         $this->posts[$i] = new PostObject($i);
         $this->connection->insert('posts', ['id' => $this->posts[$i]->getId(), 'status' => $this->posts[$i]->getStatus()]);
         $i++;
     }
 }
开发者ID:dragosprotung,项目名称:AclBundle,代码行数:19,代码来源:AclFilterTest.php

示例9: createSchema

 private function createSchema($conn)
 {
     $schema = new Schema();
     $posts = $schema->createTable('posts');
     $posts->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
     $posts->addColumn('username', 'string', array('length' => 32));
     $posts->addColumn('post_content', 'text');
     $posts->setPrimaryKey(array('id'));
     $comments = $schema->createTable('comments');
     $comments->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true));
     $comments->addColumn('post_id', 'integer', array('unsigned' => true));
     $comments->addColumn('username', 'string', array('length' => 32));
     $comments->addColumn('content', 'text');
     $comments->setPrimaryKey(array('id'));
     $queries = $schema->toSql($conn->getDatabasePlatform());
     // get queries to create this schema.
     foreach ($queries as $sql) {
         $conn->executeQuery($sql);
     }
 }
开发者ID:hidayat365,项目名称:phpindonesia.or.id-membership2,代码行数:20,代码来源:DoctrineDbalTestCase.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var Connection $conn */
     $conn = $this->getHelper('db')->getConnection();
     $table_name = $input->getArgument('table_name');
     $schema = new Schema();
     $table = $schema->createTable($table_name);
     $table->addColumn('id', 'integer');
     $table->addColumn('expires_on', 'integer');
     $table->addColumn('parent_id', 'integer', array('notnull' => false));
     $table->addColumn('runner_class', 'string');
     $table->addColumn('schedule', 'string');
     $table->addColumn('command', 'string');
     $table->setPrimaryKey(array('id'));
     $table->addForeignKeyConstraint($table, array('parent_id'), array('id'), array('onDelete' => 'CASCADE'));
     $sqls = $schema->toSql($conn->getDatabasePlatform());
     foreach ($sqls as $sql) {
         $output->writeln('Executing: ' . $sql);
         $conn->exec($sql);
     }
     $output->writeln('Done!');
 }
开发者ID:ebussola,项目名称:job-schedule-se,代码行数:22,代码来源:InitCommand.php

示例11: install

 public function install()
 {
     // create schema
     $schema = new Schema();
     $table = $schema->createTable($this->tableName);
     $table->addColumn('id', Type::INTEGER, array('autoincrement' => true));
     $table->addColumn('token', Type::STRING, array('length' => 128, 'unique' => true));
     $table->addColumn('userId', Type::INTEGER);
     $table->addColumn('expires', Type::BIGINT, array('unsigned' => true));
     $table->addIndex(array('token'));
     $table->addIndex(array('expires'));
     $table->setPrimaryKey(array('id'));
     // drop existing table
     if (in_array($this->tableName, $this->connection->getSchemaManager()->listTableNames())) {
         foreach ($schema->toDropSql($this->connection->getDatabasePlatform()) as $sql) {
             $this->connection->exec($sql);
         }
     }
     // create table
     foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
         $this->connection->exec($sql);
     }
 }
开发者ID:myurasov,项目名称:mym-auth,代码行数:23,代码来源:DoctrineAuthService.php

示例12: createSchema

 /**
  * Create Schema
  *
  * @return DBAL
  */
 public function createSchema()
 {
     $schema = new \Doctrine\DBAL\Schema\Schema();
     $table = $schema->createTable($this->tableName);
     $table->addColumn("version", "string", array("length" => 255));
     $queries = $schema->toSql($this->connection->getDatabasePlatform());
     foreach ($queries as $sql) {
         $this->connection->query($sql);
     }
     return $this;
 }
开发者ID:edisonnica,项目名称:phpmig,代码行数:16,代码来源:DBAL.php

示例13: createTable

 /**
  * Create database table.
  */
 public static function createTable(Connection $connection, $tableName = self::DEFAULT_TABLE_NAME)
 {
     $schema = new Schema();
     $myTable = $schema->createTable($tableName);
     $myTable->addColumn("machine_id", Type::INTEGER, array("unsigned" => true));
     $myTable->addColumn("last_access", Type::BIGINT, array("unsigned" => true));
     $myTable->setPrimaryKey(array("machine_id"));
     $sql = $schema->toSql($connection->getDatabasePlatform());
     foreach ($sql as $statement) {
         $connection->exec($statement);
     }
 }
开发者ID:Gendoria,项目名称:cruftflake,代码行数:15,代码来源:DoctrineConfig.php

示例14: createMigrationsTable

 public function createMigrationsTable()
 {
     /** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $sm */
     $sm = $this->dbHandler->getConnection()->getSchemaManager();
     $dbPlatform = $sm->getDatabasePlatform();
     $schema = new Schema();
     $t = $schema->createTable($this->migrationsTableName);
     $t->addColumn('migration', 'string', array('length' => 255));
     $t->addColumn('path', 'string', array('length' => 4000));
     $t->addColumn('md5', 'string', array('length' => 32));
     $t->addColumn('execution_date', 'integer', array('notnull' => false));
     $t->addColumn('status', 'integer', array('default ' => Migration::STATUS_TODO));
     $t->addColumn('execution_error', 'string', array('length' => 4000, 'notnull' => false));
     $t->setPrimaryKey(array('migration'));
     // in case users want to look up migrations by their full path
     // NB: disabled for the moment, as it causes problems on some versions of mysql which limit index length to 767 bytes,
     // and 767 bytes can be either 255 chars or 191 chars depending on charset utf8 or utf8mb4...
     //$t->addIndex(array('path'));
     foreach ($schema->toSql($dbPlatform) as $sql) {
         $this->dbHandler->exec($sql);
     }
 }
开发者ID:kaliop-uk,项目名称:ezmigrationbundle,代码行数:22,代码来源:Database.php

示例15: migrationVersion1

 /**
  * @throws \Doctrine\DBAL\DBALException
  */
 private function migrationVersion1()
 {
     $platform = $this->connection->getDatabasePlatform();
     // Version table
     $versionTable = $this->schema->createTable('vbee_version');
     $versionTable->addColumn('version', 'integer');
     $versionTable->setPrimaryKey(['version']);
     // Person table
     $personTable = $this->schema->createTable('vbee_person');
     $personTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $personTable->addColumn('birthDate', 'date');
     $personTable->addColumn('description', 'string');
     $personTable->addColumn('email', 'string');
     $personTable->addColumn('familyName', 'string');
     $personTable->addColumn('gender', 'string');
     $personTable->addColumn('givenName', 'string');
     $personTable->addColumn('image', 'string');
     $personTable->addColumn('jobTitle', 'string');
     $personTable->addColumn('nationality', 'string');
     $personTable->addColumn('telephone', 'string');
     $personTable->addUniqueIndex(['id']);
     $personTable->setPrimaryKey(['id']);
     // Organization table
     $organizationTable = $this->schema->createTable('vbee_organization');
     $organizationTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $organizationTable->addColumn('address', 'string');
     $organizationTable->addColumn('description', 'string');
     $organizationTable->addColumn('email', 'string');
     $organizationTable->addColumn('location', 'string');
     $organizationTable->addColumn('logo', 'string');
     $organizationTable->addColumn('name', 'string');
     $organizationTable->addColumn('numberOfEmployees', 'string');
     $organizationTable->addColumn('telephone', 'string');
     $organizationTable->addUniqueIndex(['id']);
     $organizationTable->setPrimaryKey(['id']);
     // Experience table
     $experienceTable = $this->schema->createTable('vbee_experience');
     $experienceTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $experienceTable->addColumn('type', 'string');
     $experienceTable->addColumn('startDate', 'date');
     $experienceTable->addColumn('endDate', 'date');
     $experienceTable->addColumn('personId', 'integer', ['unsigned' => true]);
     $experienceTable->addColumn('organizationId', 'integer', ['unsigned' => true]);
     $experienceTable->addForeignKeyConstraint($personTable, ["personId"], ["id"]);
     $experienceTable->addForeignKeyConstraint($organizationTable, ["organizationId"], ["id"]);
     $experienceTable->addUniqueIndex(['id']);
     $experienceTable->setPrimaryKey(['id']);
     // Mission table
     $missionTable = $this->schema->createTable('vbee_mission');
     $missionTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $missionTable->addColumn('description', 'string');
     $missionTable->addColumn('title', 'string');
     $missionTable->addColumn('startDate', 'date');
     $missionTable->addColumn('endDate', 'date');
     $missionTable->addColumn('experienceId', 'integer', ['unsigned' => true]);
     $missionTable->addForeignKeyConstraint($experienceTable, ["experienceId"], ["id"]);
     $missionTable->addUniqueIndex(['id']);
     $missionTable->setPrimaryKey(['id']);
     $skillTable = $this->schema->createTable('vbee_skill');
     $skillTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $skillTable->addColumn('level', 'integer');
     $skillTable->addColumn('name', 'string');
     $skillTable->addColumn('personId', 'integer', ['unsigned' => true]);
     $skillTable->addForeignKeyConstraint($personTable, ["personId"], ["id"]);
     $skillTable->addUniqueIndex(['id']);
     $skillTable->setPrimaryKey(['id']);
     $studyTable = $this->schema->createTable('vbee_study');
     $studyTable->addColumn('id', 'integer', ['unsigned' => true, 'autoincrement' => true]);
     $studyTable->addColumn('description', 'string');
     $studyTable->addColumn('graduation', 'string');
     $studyTable->addColumn('name', 'string');
     $studyTable->addColumn('startDate', 'date');
     $studyTable->addColumn('endDate', 'date');
     $studyTable->addColumn('personId', 'integer', ['unsigned' => true]);
     $studyTable->addForeignKeyConstraint($personTable, ["personId"], ["id"]);
     $studyTable->addUniqueIndex(['id']);
     $studyTable->setPrimaryKey(['id']);
     // Execute schema migration
     foreach ($this->schema->toSql($platform) as $query) {
         $statement = $this->connection->prepare($query);
         $statement->execute();
     }
     // Create the version row
     $this->connection->createQueryBuilder()->insert('vbee_version')->values(['version' => '0'])->execute();
 }
开发者ID:VincentBee,项目名称:vbee_site,代码行数:88,代码来源:SchemaManager.php


注:本文中的Doctrine\DBAL\Schema\Schema::toSql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。