本文整理汇总了PHP中Propel\Generator\Util\QuickBuilder类的典型用法代码示例。如果您正苦于以下问题:PHP QuickBuilder类的具体用法?PHP QuickBuilder怎么用?PHP QuickBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuickBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
if (!class_exists('\\ChildTable')) {
$schema = <<<EOF
<database name="composite_number_range_test">
<table name="parent_table">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="name" type="VARCHAR" required="false" />
</table>
<table name="child_table">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="name" type="VARCHAR" size="50" required="false" />
<behavior name="\\APinnecke\\CompositeNumberRange\\CompositeNumberRangeBehavior">
<parameter name="foreignTable" value="parent_table"/>
</behavior>
</table>
</database>
EOF;
$builder = new QuickBuilder();
$builder->setPlatform(new MysqlPlatform());
$builder->setSchema($schema);
$builder->build('mysql:host=127.0.0.1;dbname=' . getenv('DB_NAME'), getenv('DB_USER'), getenv('DB_PASS'), new MysqlAdapter());
}
$this->parent = new \ParentTable();
$this->parent->setName('test');
$this->parent->save();
$this->parent2 = new \ParentTable();
$this->parent2->setName('test2');
$this->parent2->save();
\ChildTableQuery::create()->deleteAll();
\ParentTableSequenceQuery::create()->deleteAll();
}
开发者ID:apinnecke,项目名称:composite-number-range-behavior,代码行数:32,代码来源:CompositeNumberRangeBehaviorTest.php
示例2: applyXml
/**
* @param string $xml
*
* @return Database
*/
public function applyXml($xml)
{
$this->readDatabase();
$builder = new QuickBuilder();
$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) {
return null;
}
$sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
$this->con->beginTransaction();
$statements = SqlParser::parseString($sql);
foreach ($statements as $statement) {
try {
$stmt = $this->con->prepare($statement);
$stmt->execute();
} catch (\Exception $e) {
$this->con->rollBack();
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;
}
示例3: 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;
}
示例4: setUp
public function setUp()
{
if (!class_exists('\\Issue656TestObject')) {
$schema = <<<EOF
<database>
<table name="issue_656_test_object">
<column name="ID" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true" autoIncrement="true"/>
<column name="Name" type="VARCHAR" size="45" required="true"/>
</table>
<table name="issue_656_test_object_from" isCrossRef="true">
<column name="From" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true"/>
<column name="To" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true"/>
<foreign-key name="fk_test_object_from" foreignTable="issue_656_test_object">
<reference local="From" foreign="ID"/>
</foreign-key>
<foreign-key name="fk_test_object_to" foreignTable="issue_656_test_object">
<reference local="To" foreign="ID"/>
</foreign-key>
</table>
</database>
EOF;
$builder = new QuickBuilder();
$builder->setSchema($schema);
$builder->buildClasses(null, true);
}
}
示例5: setUp
public function setUp()
{
parent::setUp();
$schema = file_get_contents(__DIR__ . '/../Resources/acl_schema.xml');
if (!class_exists('Propel\\Bundle\\PropelBundle\\Model\\Acl\\Map\\AclClassTableMap')) {
$classTargets = array('tablemap', 'object', 'query');
} else {
$classTargets = array();
}
$builder = new QuickBuilder();
$builder->setSchema($schema);
$this->con = $builder->build($dsn = null, $user = null, $pass = null, $adapter = null, $classTargets);
}
示例6: setUp
public function setUp()
{
if (!class_exists('MyNameSpace\\ComplexColumnTypeEntitySet')) {
$schema = <<<EOF
<database name="generated_object_complex_type_test_set" namespace="MyNameSpace">
<table name="complex_column_type_entity_set">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="tags" type="SET" valueSet="foo, bar, baz, 1, 4,(, foo bar " />
<column name="bar" type="SET" valueSet="foo, bar" />
<column name="defaults" type="SET" valueSet="foo, bar, foo baz" defaultValue="bar" />
<column name="bears" type="SET" valueSet="foo, bar, baz, kevin" defaultValue="bar, baz" />
</table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
// ok this is hackish but it makes testing of getter and setter independent of each other
$publicAccessorCode = <<<EOF
class PublicComplexColumnTypeEntitySet extends MyNameSpace\\ComplexColumnTypeEntitySet
{
public \$bar;
public \$tags;
}
EOF;
eval($publicAccessorCode);
}
ComplexColumnTypeEntitySetTableMap::doDeleteAll();
}
示例7: setUp
public function setUp()
{
parent::setUp();
if (!class_exists('ConcreteInheritanceBehaviorWithBehaviorExclusionTest\\ConcreteInheritanceParentQuery')) {
$schema = <<<EOF
<database name="concrete_inheritance_behavior_exclusion" namespace="ConcreteInheritanceBehaviorWithBehaviorExclusionTest">
<table name="concrete_inheritance_parent" allowPkInsert="true">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
<behavior name="sluggable">
<parameter name="scope_column" value="title" />
</behavior>
<behavior name="timestampable" />
<index>
<index-column name="title" />
</index>
</table>
<table name="concrete_inheritance_child" allowPkInsert="true">
<column name="body" type="longvarchar" />
<column name="author_id" required="false" type="INTEGER" />
<behavior name="concrete_inheritance">
<parameter name="extends" value="concrete_inheritance_parent" />
<parameter name="copy_data_to_child" value="slug" />
<parameter name="exclude_behaviors" value="sluggable" />
</behavior>
</table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
}
}
示例8: setUp
public function setUp()
{
if (!class_exists('\\Issue733Test1')) {
$schema = <<<EOF
<database name="issue_733_test">
<table name="issue_733_test_1">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="foo" type="INTEGER" />
<column name="bar" type="VARCHAR" size="100" />
<behavior name="i18n">
<parameter name="i18n_columns" value="bar" />
<parameter name="locale_column" value="language" />
</behavior>
</table>
<table name="issue_733_test_2">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="foo" type="INTEGER" />
<column name="bar" type="VARCHAR" size="100" />
<behavior name="i18n">
<parameter name="i18n_columns" value="bar" />
<parameter name="locale_column" value="language" />
<parameter name="locale_alias" value="culture" />
</behavior>
</table>
</database>
EOF;
$this->con = QuickBuilder::buildSchema($schema);
}
}
示例9: setUp
public function setUp()
{
if (!class_exists('\\OptimisticLockingTable')) {
$schema = <<<EOF
<database name="optimistic_locker_behavior_test">
<table name="optimistic_locking_table">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
<column name="age" type="INTEGER" />
<column name="related_id" type="INTEGER" />
<behavior name="MJS\\OptimisticLocking\\OptimisticLockingBehavior" />
<foreign-key foreignTable="optimistic_locking_related_table">
<reference local="related_id" foreign="id" />
</foreign-key>
</table>
<table name="optimistic_locking_related_table">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="name" type="VARCHAR" size="100" primaryString="true" />
</table>
<table name="optimistic_locking_versionable_table">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
<column name="age" type="INTEGER" />
<column name="related_id" type="INTEGER" />
<behavior name="MJS\\OptimisticLocking\\OptimisticLockingBehavior" />
<behavior name="versionable" />
</table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
}
}
示例10: setUp
public function setUp()
{
if (!class_exists('\\I18nBehaviorTest11')) {
$schema = <<<EOF
<database name="i18n_behavior_test_10" identifierQuoting="true">
<table name="i18n_behavior_test_11">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="foo" type="INTEGER" />
<column name="bar" type="VARCHAR" size="100" />
<behavior name="i18n">
<parameter name="i18n_columns" value="bar" />
</behavior>
</table>
<table name="i18n_behavior_test_12">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="foo" type="INTEGER" />
<column name="bar1" type="VARCHAR" size="100" />
<column name="bar2" type="LONGVARCHAR" lazyLoad="true" />
<column name="bar3" type="TIMESTAMP" />
<column name="bar4" type="LONGVARCHAR" description="This is the Bar4 column" />
<behavior name="i18n">
<parameter name="i18n_columns" value="bar1,bar2,bar3,bar4" />
<parameter name="default_locale" value="fr_FR" />
<parameter name="locale_alias" value="culture" />
</behavior>
</table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
}
}
示例11: setUp
public function setUp()
{
$this->c1 = new FooColumnValue2();
$this->c1->bar = 1234;
$this->c2 = new FooColumnValue2();
$this->c2->bar = 5678;
if (!class_exists('ComplexColumnTypeEntity10')) {
$schema = <<<EOF
<database name="generated_query_complex_type_test_10">
<table name="complex_column_type_entity_10">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="bar" type="OBJECT" />
</table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
$e0 = new \ComplexColumnTypeEntity10();
$e0->save();
$e1 = new \ComplexColumnTypeEntity10();
$e1->setBar($this->c1);
$e1->save();
$e2 = new \ComplexColumnTypeEntity10();
$e2->setBar($this->c2);
$e2->save();
\ComplexColumnTypeEntity10Peer::clearInstancePool();
}
}
示例12: testObjectColumnType
public function testObjectColumnType()
{
$schema = <<<EOF
<database name="generated_object_complex_type_test_1">
<table name="complex_column_type_entity_1">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="bar" type="OBJECT" />
</table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
$e = new \ComplexColumnTypeEntity1();
$this->assertNull($e->getBar(), 'object columns are null by default');
$c = new FooColumnValue();
$c->bar = 1234;
$e->setBar($c);
$this->assertEquals($c, $e->getBar(), 'object columns can store objects');
$e->setBar(null);
$this->assertNull($e->getBar(), 'object columns are nullable');
$e->setBar($c);
$e->save();
\ComplexColumnTypeEntity1Peer::clearInstancePool();
$e = \ComplexColumnTypeEntity1Query::create()->findOne();
$this->assertEquals($c, $e->getBar(), 'object columns are persisted');
}
示例13: setUp
public function setUp()
{
if (!class_exists('\\Base\\Issue1033Book')) {
$schema = <<<EOF
<database>
<table name="Issue1033Book">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" description="Book Id" />
<column name="title" type="VARCHAR" required="true" description="Book Title" primaryString="true" />
</table>
</database>
EOF;
$builder = new QuickBuilder();
$builder->setSchema($schema);
$builder->buildClasses(null, true);
}
}
示例14: setUp
public function setUp()
{
if (!class_exists('\\ComplexColumnTypeEntity11')) {
$schema = <<<EOF
<database name="generated_object_complex_type_test_11">
<table name="complex_column_type_entity_11">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="tags" type="ARRAY" />
<column name="value_set" type="ARRAY" />
</table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
$e0 = new \ComplexColumnTypeEntity11();
$e0->save();
$e1 = new \ComplexColumnTypeEntity11();
$e1->setTags(array('foo', 'bar', 'baz'));
$e1->save();
$e2 = new \ComplexColumnTypeEntity11();
$e2->setTags(array('bar'));
$e2->save();
$e3 = new \ComplexColumnTypeEntity11();
$e3->setTags(array('bar23'));
$e3->save();
}
}
示例15: setUp
protected function setUp()
{
parent::setUp();
if (!class_exists('\\Nature')) {
$schema = '
<database>
<table name="recherche" phpName="Recherche">
<column name="id" type="integer" primaryKey="true" autoIncrement="true"/>
</table>
<table name="recherche_nature" phpName="RechercheNature" isCrossRef="true">
<column name="recherche_id" type="integer" primaryKey="true"/>
<column name="nature_id" type="integer" primaryKey="true"/>
<foreign-key foreignTable="recherche" onDelete="cascade">
<reference local="recherche_id" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="nature">
<reference local="nature_id" foreign="id"/>
</foreign-key>
</table>
<table name="nature" phpName="Nature">
<column name="id" type="integer" primaryKey="true" autoIncrement="true"/>
</table>
</database>
';
QuickBuilder::buildSchema($schema);
}
}