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


PHP QuickBuilder::setIdentifierQuoting方法代码示例

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


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

示例1: applyXml

 /**
  * @param string $xml
  *
  * @return Database|boolean
  */
 public function applyXml($xml, $changeRequired = false)
 {
     $this->readDatabase();
     $builder = new QuickBuilder();
     $builder->setIdentifierQuoting(true);
     $builder->setPlatform($this->database->getPlatform());
     $builder->setSchema($xml);
     $database = $builder->getDatabase();
     $database->setSchema('migration');
     $database->setPlatform($this->database->getPlatform());
     $diff = DatabaseComparator::computeDiff($this->database, $database);
     if (false === $diff) {
         if ($changeRequired) {
             throw new BuildException(sprintf("No changes in schema to current database: \nSchema database:\n%s\n\nCurrent Database:\n%s", $database, $this->database));
         }
         return false;
     }
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $this->con->beginTransaction();
     if (!$sql) {
         throw new BuildException(sprintf('Ooops. There is a diff between current database and schema xml but no SQL has been generated. Change: %s', $diff));
     }
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         try {
             $stmt = $this->con->prepare($statement);
             $stmt->execute();
         } catch (\Exception $e) {
             throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
         }
     }
     $this->con->commit();
     return $database;
 }
开发者ID:disider,项目名称:Propel2,代码行数:39,代码来源:MigrationTestCase.php

示例2: dropForeignKey

    /**
     * Drop the foreign key in the `_user` table and check whether it generates
     * the correct `DROP` SQL.
     */
    private function dropForeignKey()
    {
        $this->readDatabase();
        $updatedSchema = '
<database name="reverse-bookstore" identifierQuoting="true">
<table name="issue617_user">
  <vendor type="mysql">
    <parameter name="Engine" value="InnoDB"/>
    <parameter name="Charset" value="utf8"/>
  </vendor>
  <column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
  <column name="full_name" type="VARCHAR" size="50" required="true" />
</table>

<table name="issue617_group">
  <vendor type="mysql">
    <parameter name="Engine" value="InnoDB"/>
    <parameter name="Charset" value="utf8"/>
  </vendor>
  <column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
  <column name="name" type="VARCHAR" size="50" required="true" />
</table>
</database>
';
        $this->updatedBuilder = new QuickBuilder();
        $this->updatedBuilder->setIdentifierQuoting(true);
        $this->updatedBuilder->setPlatform($this->database->getPlatform());
        $this->updatedBuilder->setSchema($updatedSchema);
        $diff = DatabaseComparator::computeDiff($this->database, $this->updatedBuilder->getDatabase());
        $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
        $expected = '
ALTER TABLE `issue617_user` DROP FOREIGN KEY `issue617_user_fk_5936b3`;

DROP INDEX `issue617_user_fi_5936b3` ON `issue617_user`;

ALTER TABLE `issue617_user`

  DROP `group_id`;
';
        $this->assertContains($expected, $sql);
        $this->updateSchema($this->updatedBuilder->getDatabase());
    }
开发者ID:disider,项目名称:Propel2,代码行数:46,代码来源:Issue617Test.php

示例3: testNamespace

    public function testNamespace()
    {
        $schema = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<database name="default" defaultIdMethod="native" namespace="Tests\\Issue730\\">
    <table name="issue730_group" idMethod="native" phpName="Group">
        <column name="id" phpName="Id" type="INTEGER" primaryKey="true" required="true"/>
        <column name="name" phpName="Name" type="VARCHAR" size="100" required="true"/>
    </table>
    <table name="issue730_department_group" idMethod="native" phpName="Group" namespace="\\Tests\\Issue730\\Department">
        <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
        <column name="name" type="VARCHAR" size="100" required="true"/>
        <column name="group_id" phpName="GroupId" type="INTEGER"/>

        <foreign-key foreignTable="issue730_group" phpName="Group" refPhpName="DepartmentGroup">
            <reference local="group_id" foreign="id"/>
        </foreign-key>
    </table>
</database>
EOF;
        $quickBuilder = new QuickBuilder();
        $quickBuilder->setSchema($schema);
        $quickBuilder->setIdentifierQuoting(true);
        $platform = new SqlitePlatform();
        $quickBuilder->setPlatform($platform);
        $quickBuilder->build();
        $groupA = new \Tests\Issue730\Group();
        $groupA->setName('groupA');
        $departmentGroup = new \Tests\Issue730\Department\Group();
        $departmentGroup->setName('my department');
        $departmentGroup->setGroup($groupA);
        $this->assertEquals($groupA, $departmentGroup->getGroup());
        $departmentGroups = $groupA->getDepartmentGroups();
        $this->assertCount(1, $departmentGroups);
        $this->assertEquals($departmentGroup, $departmentGroups->getFirst());
        $groupA->save();
        $departmentGroups = \Tests\Issue730\Department\GroupQuery::create()->filterByGroup($groupA)->find();
        $this->assertCount(1, $departmentGroups);
        $this->assertEquals($departmentGroup, $departmentGroups->getFirst());
        $this->assertEquals('my department', $departmentGroups->getFirst()->getName());
    }
开发者ID:disider,项目名称:Propel2,代码行数:41,代码来源:Issue730Test.php


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