本文整理汇总了PHP中Propel\Generator\Util\QuickBuilder::build方法的典型用法代码示例。如果您正苦于以下问题:PHP QuickBuilder::build方法的具体用法?PHP QuickBuilder::build怎么用?PHP QuickBuilder::build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Util\QuickBuilder
的用法示例。
在下文中一共展示了QuickBuilder::build方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: setUp
public function setUp()
{
if (!class_exists('TableWithStateMachineBehavior')) {
$schema = <<<EOF
<database name="state_machine_behavior" defaultIdMethod="native">
<table name="table_with_state_machine_behavior">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<behavior name="state_machine">
<parameter name="states" value="draft, unpublished, published" />
<parameter name="initial_state" value="draft" />
<parameter name="transition" value="draft to published with publish" />
<parameter name="transition" value="published to unpublished with unpublish" />
<parameter name="transition" value="unpublished to published with publish" />
<parameter name="state_column" value="state" />
</behavior>
</table>
<table name="table_with_state_machine_behavior_with_custom_column">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<behavior name="state_machine">
<parameter name="states" value="draft, published, not_yEt_published, flagged" />
<parameter name="initial_state" value="draft" />
<parameter name="transition" value="draft to published with publish" />
<parameter name="transition" value="published to not_yet_published with unpublish" />
<parameter name="transition" value="not_yEt_published to published with publish" />
<parameter name="transition" value="not_yEt_published to flagged with flag_for_publish" />
<parameter name="transition" value="flagged to published with publish" />
<parameter name="state_column" value="my_state" />
</behavior>
</table>
</database>
EOF;
$builder = new QuickBuilder();
$config = $builder->getConfig();
$builder->setConfig($config);
$builder->setSchema($schema);
$builder->build();
}
}
示例4: setUp
public function setUp()
{
$schema = <<<SCHEMA
<database name="users" defaultIdMethod="native" namespace="Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\Model">
<table name="user">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="username" type="varchar" size="255" primaryString="true" />
<column name="algorithm" type="varchar" size="50" />
<column name="salt" type="varchar" size="255" />
<column name="password" type="varchar" size="255" />
<column name="expires_at" type="timestamp" />
<column name="roles" type="array" />
</table>
</database>
SCHEMA;
$builder = new QuickBuilder();
$builder->setSchema($schema);
$classTargets = array('tablemap', 'object', 'query', 'querystub');
$this->con = $builder->build($dsn = null, $user = null, $pass = null, $adapter = null, $classTargets);
}
示例5: 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());
}
示例6: setUp
/**
* Setup schema und some default data
*/
public function setUp()
{
parent::setUp();
if (!class_exists('MoreRelationTest\\Page')) {
$schema = <<<EOF
<database name="more_relation_test" namespace="MoreRelationTest">
<table name="more_relation_test_page" phpName="Page">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
</table>
<table name="more_relation_test_content" phpName="Content">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" />
<column name="content" type="LONGVARCHAR" required="false" />
<column name="page_id" type="INTEGER" required="false" />
<foreign-key foreignTable="more_relation_test_page" onDelete="cascade">
<reference local="page_id" foreign="id"/>
</foreign-key>
</table>
<table name="more_relation_test_comment" phpName="Comment">
<column name="user_id" required="true" primaryKey="true" type="INTEGER" />
<column name="page_id" required="true" primaryKey="true" type="INTEGER" />
<column name="comment" type="VARCHAR" size="100" />
<foreign-key foreignTable="more_relation_test_page" onDelete="cascade">
<reference local="page_id" foreign="id"/>
</foreign-key>
</table>
<table name="more_relation_test_content_comment" phpName="ContentComment">
<column name="id" required="true" autoIncrement="true" primaryKey="true" type="INTEGER" />
<column name="content_id" type="INTEGER" />
<column name="comment" type="VARCHAR" size="100" />
<foreign-key foreignTable="more_relation_test_content" onDelete="setnull">
<reference local="content_id" foreign="id"/>
</foreign-key>
</table>
</database>
EOF;
$builder = new QuickBuilder();
$builder->setSchema($schema);
$builder->build();
}
\MoreRelationTest\ContentCommentQuery::create()->doDeleteAll();
\MoreRelationTest\ContentQuery::create()->doDeleteAll();
\MoreRelationTest\CommentQuery::create()->doDeleteAll();
\MoreRelationTest\PageQuery::create()->doDeleteAll();
for ($i = 1; $i <= 2; $i++) {
$page = new \MoreRelationTest\Page();
$page->setTitle('Page ' . $i);
for ($j = 1; $j <= 3; $j++) {
$content = new \MoreRelationTest\Content();
$content->setTitle('Content ' . $j);
$content->setContent(str_repeat('Content', $j));
$page->addContent($content);
$comment = new \MoreRelationTest\Comment();
$comment->setUserId($j);
$comment->setComment(str_repeat('Comment', $j));
$page->addComment($comment);
$comment = new \MoreRelationTest\ContentComment();
$comment->setContentId($i * $j);
$comment->setComment(str_repeat('Comment-' . $j . ', ', $j));
$content->addContentComment($comment);
}
$page->save();
}
}
示例7: testBuild
public function testBuild()
{
$xmlSchema = <<<EOF
<database name="test_quick_build_2" namespace="MyNameSpace2">
<table name="quick_build_foo_2">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="bar" type="INTEGER" />
</table>
</database>
EOF;
$builder = new QuickBuilder();
$builder->setSchema($xmlSchema);
$builder->build();
$this->assertEquals(0, QuickBuildFoo2Query::create()->count());
$foo = new QuickBuildFoo2();
$foo->setBar(3);
$foo->save();
$this->assertEquals(1, QuickBuildFoo2Query::create()->count());
$this->assertEquals($foo, QuickBuildFoo2Query::create()->findOne());
}
示例8: setUp
public function setUp()
{
if (!class_exists('\\ArchivableTest1')) {
$schema = <<<EOF
<database name="archivable_behavior_test_0">
<table name="archivable_test_1">
<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="foo_id" type="INTEGER" />
<foreign-key foreignTable="archivable_test_2">
<reference local="foo_id" foreign="id" />
</foreign-key>
<index>
<index-column name="title" />
<index-column name="age" />
</index>
<behavior name="archivable" />
</table>
<table name="archivable_test_2">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
<behavior name="archivable" />
</table>
<table name="archivable_test_2_archive">
<column name="id" required="true" primaryKey="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
</table>
<table name="archivable_test_3">
<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="foo_id" type="INTEGER" />
<unique>
<unique-column name="title" />
</unique>
<behavior name="archivable">
<parameter name="log_archived_at" value="false" />
<parameter name="archive_table" value="my_old_archivable_test_3" />
<parameter name="archive_on_insert" value="true" />
<parameter name="archive_on_update" value="true" />
<parameter name="archive_on_delete" value="false" />
</behavior>
</table>
<table name="archivable_test_4">
<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" />
<behavior name="archivable">
<parameter name="archive_class" value="\\Propel\\Tests\\Generator\\Behavior\\Archivable\\FooArchive" />
</behavior>
</table>
<table name="archivable_test_5">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<behavior name="archivable">
<parameter name="archive_table" value="archivable_test_5_backup" />
<parameter name="archive_phpname" value="ArchivableTest5MyBackup" />
</behavior>
</table>
</database>
EOF;
$builder = new QuickBuilder();
$builder->setSchema($schema);
self::$generatedSQL = $builder->getSQL();
$builder->build();
}
}
示例9: testDisableCreatedAt
public function testDisableCreatedAt()
{
$schema = <<<EOF
<database name="timestampable_database">
<table name="table_without_created_at">
<column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" />
<column name="name" type="varchar" />
<behavior name="timestampable">
<parameter name="disable_created_at" value="true" />
</behavior>
</table>
</database>
EOF;
$builder = new QuickBuilder();
$builder->setSchema($schema);
$builder->build();
$this->assertFalse(method_exists('TableWithoutCreatedAt', 'getCreatedAt'));
$this->assertFalse(method_exists('TableWithoutCreatedAt', 'setCreatedAt'));
$this->assertTrue(method_exists('TableWithoutCreatedAt', 'getUpdatedAt'));
$this->assertTrue(method_exists('TableWithoutCreatedAt', 'setUpdatedAt'));
$obj = new \TableWithoutCreatedAt();
$obj->setName('Peter');
$this->assertNull($obj->getUpdatedAt());
$this->assertEquals(1, $obj->save());
$this->assertNotNull($obj->getUpdatedAt());
}
示例10: testLoadDelegatedOnPrimaryKey
public function testLoadDelegatedOnPrimaryKey()
{
$schema = <<<XML
<database name="default" package="vendor.bundles.Propel.Bundle.PropelBundle.Tests.Fixtures.DataFixtures.Loader" namespace="Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\DataFixtures\\Loader" defaultIdMethod="native">
<table name="yaml_delegate_on_primary_key_person" phpName="YamlDelegateOnPrimaryKeyPerson">
<column name="id" type="integer" primaryKey="true" autoIncrement="true" />
<column name="name" type="varchar" size="255" />
</table>
<table name="yaml_delegate_on_primary_key_author" phpName="YamlDelegateOnPrimaryKeyAuthor">
<column name="id" type="integer" primaryKey="true" autoIncrement="false" />
<column name="count_books" type="integer" defaultValue="0" required="true" />
<behavior name="delegate">
<parameter name="to" value="yaml_delegate_on_primary_key_person" />
</behavior>
<foreign-key foreignTable="yaml_delegate_on_primary_key_person" onDelete="RESTRICT" onUpdate="CASCADE">
<reference local="id" foreign="id" />
</foreign-key>
</table>
</database>
XML;
$fixtures = <<<YAML
Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\DataFixtures\\Loader\\YamlDelegateOnPrimaryKeyPerson:
yaml_delegate_on_primary_key_person_1:
name: "Some Persons Name"
Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\DataFixtures\\Loader\\YamlDelegateOnPrimaryKeyAuthor:
yaml_delegate_on_primary_key_author_1:
id: yaml_delegate_on_primary_key_person_1
count_books: 7
YAML;
$filename = $this->getTempFile($fixtures);
$builder = new QuickBuilder();
$builder->setSchema($schema);
$con = $builder->build();
$loader = new YamlDataLoader(__DIR__ . '/../../Fixtures/DataFixtures/Loader', array());
$loader->load(array($filename), 'default');
$authors = \Propel\Bundle\PropelBundle\Tests\Fixtures\DataFixtures\Loader\YamlDelegateOnPrimaryKeyAuthorQuery::create()->find($con);
$this->assertCount(1, $authors);
$author = $authors[0];
$person = $author->getYamlDelegateOnPrimaryKeyPerson();
$this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\DataFixtures\\Loader\\YamlDelegateOnPrimaryKeyPerson', $person);
}