本文整理汇总了PHP中PropelQuickBuilder::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP PropelQuickBuilder::getDatabase方法的具体用法?PHP PropelQuickBuilder::getDatabase怎么用?PHP PropelQuickBuilder::getDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropelQuickBuilder
的用法示例。
在下文中一共展示了PropelQuickBuilder::getDatabase方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDeletedFk
private function checkDeletedFk()
{
$this->readDatabase();
$diff = DatabaseComparator::computeDiff($this->database, $this->updatedBuilder->getDatabase());
$sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
$expected = 'issue617_user';
$this->assertNotContains($expected, $sql);
}
示例2: checkDeletedFk
private function checkDeletedFk()
{
$this->readDatabase();
$diff = PropelDatabaseComparator::computeDiff($this->database, $this->updatedBuilder->getDatabase());
$sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
$expected = '
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `book`;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
';
$this->assertEquals($expected, $sql);
}
示例3: testValidateReturnsTrueForValidSchema
public function testValidateReturnsTrueForValidSchema()
{
$schema = <<<EOF
<database name="bookstore">
\t<table name="book">
\t\t<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
\t\t<column name="title" type="VARCHAR" size="100" primaryString="true" />
\t</table>
</database>
EOF;
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$database = $builder->getDatabase();
$appData = new AppData();
$appData->addDatabase($database);
$validator = new PropelSchemaValidator($appData);
$this->assertTrue($validator->validate());
}
示例4: testTableWithPrefix
public function testTableWithPrefix()
{
$schema = <<<EOF
<database name="default" tablePrefix="plop_">
<table name="group">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="title" type="varchar" primaryString="true" size="255" />
<behavior name="i18n">
<parameter name="i18n_columns" value="title" />
<parameter name="locale_column" value="locale" />
</behavior>
</table>
</database>
EOF;
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$this->assertTrue($builder->getDatabase()->hasTable('plop_group'));
$this->assertFalse($builder->getDatabase()->hasTable('plop_plop_group_i18n'));
$this->assertTrue($builder->getDatabase()->hasTable('plop_group_i18n'));
}
示例5: testModiFyTableDoesNotMoveValidatorsOnNonI18nColumns
public function testModiFyTableDoesNotMoveValidatorsOnNonI18nColumns()
{
$schema = <<<EOF
<database name="i18n_behavior_test_0">
\t<table name="i18n_behavior_test_0">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<validator column="id">
\t\t\t<rule name="minLength" value="4" message="title must be at least 4 characters !" />
\t\t</validator>
\t\t<column name="title" type="VARCHAR" />
\t\t<behavior name="i18n">
\t\t\t<parameter name="i18n_columns" value="title" />
\t\t</behavior>
\t</table>
</database>
EOF;
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$table = $builder->getDatabase()->getTable('i18n_behavior_test_0');
$this->assertEquals(1, count($table->getValidators()));
$i18nTable = $builder->getDatabase()->getTable('i18n_behavior_test_0_i18n');
$this->assertEquals(array(), $i18nTable->getValidators());
}
示例6: testValidateReturnsFalseWhenCrossRefTableHasTwoFksToTheSameTable
public function testValidateReturnsFalseWhenCrossRefTableHasTwoFksToTheSameTable()
{
$schema = <<<EOF
<database name="bookstore">
<table name="book">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
</table>
<table name="book_book" isCrossRef="true">
<column name="parent_id" type="INTEGER" primaryKey="true" required="true"/>
<column name="child_id" type="INTEGER" primaryKey="true" required="true"/>
<foreign-key foreignTable="book">
<reference local="child_id" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="book">
<reference local="parent_id" foreign="id"/>
</foreign-key>
</table>
</database>
EOF;
$builder = new PropelQuickBuilder();
$builder->setSchema($schema);
$database = $builder->getDatabase();
$appData = new AppData();
$appData->addDatabase($database);
$validator = new PropelSchemaValidator($appData);
$this->assertFalse($validator->validate());
$this->assertContains('Table "book_book" implements an equal nest relationship for table "book". This feature is not supported', $validator->getErrors());
}
示例7: loadAndBuild
protected function loadAndBuild()
{
$this->loadPropelQuickBuilder();
if (!class_exists('Glorpen\\Propel\\PropelBundle\\Tests\\Fixtures\\Model\\Book', false)) {
$builder = new \PropelQuickBuilder();
$builder->getConfig()->setBuildProperty('behaviorEventClass', 'Behaviors.EventBehavior');
$builder->getConfig()->setBuildProperty('behaviorExtendClass', 'Behaviors.ExtendBehavior');
$builder->setSchema(static::$schema);
$builder->setClassTargets(array('tablemap', 'peer', 'object', 'query', 'peerstub', 'querystub'));
file_put_contents("/tmp/a.php", $builder->getClasses());
$builder->build();
$con = new EventPropelPDO('sqlite::memory:');
$con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
$name = $builder->getDatabase()->getName();
\Propel::setConnection($name, $con, \Propel::CONNECTION_READ);
\Propel::setConnection($name, $con, \Propel::CONNECTION_WRITE);
$builder->buildSQL($con);
}
}