本文整理汇总了PHP中RedBeanPHP\Facade::renameAssociation方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::renameAssociation方法的具体用法?PHP Facade::renameAssociation怎么用?PHP Facade::renameAssociation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::renameAssociation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testViaPrettification
/**
* Test prettier tables using via().
*/
public function testViaPrettification()
{
R::nuke();
R::renameAssociation('tbl_author_tbl_friend', 'tbl_author_friend');
$author = R::xdispense(AUTHOR);
$author->name = 'Mr. Quill';
$friend = R::xdispense(FRIEND);
$friend->name = 'Muse';
$author->{FRIENDLIST}[] = $friend;
$id = R::store($author);
//print_r(R::inspect()); exit;
$author = R::load(AUTHOR, $id);
$tables = array_flip(R::inspect());
asrt(isset($tables['tbl_author_friend']), TRUE);
asrt(isset($tables['tbl_author_tbl_friend']), FALSE);
asrt(count($author->{FRIENDLIST}), 1);
AQueryWriter::clearRenames();
}
示例2: testAssociationRenaming
/**
* test emulation via association renaming
*
* @return void
*/
public function testAssociationRenaming()
{
list($p1, $p2, $p3) = R::dispense('painting', 3);
list($m1, $m2, $m3) = R::dispense('museum', 3);
$p1->name = 'painting1';
$p2->name = 'painting2';
$p3->name = 'painting3';
$m1->thename = 'a';
$m2->thename = 'b';
$m3->thename = 'c';
R::renameAssociation('museum_painting', 'exhibited');
// Also test array syntax
R::renameAssociation(array('museum_museum' => 'center'));
$m1->link('center', array('name' => 'History Center'))->museum2 = $m2;
$m1->link('exhibited', '{"from":"2014-02-01","til":"2014-07-02"}')->painting = $p3;
$m2->link('exhibited', '{"from":"2014-07-03","til":"2014-10-02"}')->painting = $p3;
$m3->link('exhibited', '{"from":"2014-02-01","til":"2014-07-02"}')->painting = $p1;
$m2->link('exhibited', '{"from":"2014-02-01","til":"2014-07-02"}')->painting = $p2;
R::storeAll(array($m1, $m2, $m3));
list($m1, $m2, $m3) = array_values(R::findAll('museum', ' ORDER BY thename ASC'));
asrt(count($m1->sharedMuseum), 1);
asrt(count($m1->sharedPainting), 1);
asrt(count($m2->sharedPainting), 2);
asrt(count($m3->sharedPainting), 1);
$p3 = reset($m1->sharedPainting);
asrt(count($p3->ownExhibited), 2);
asrt(count($m2->ownExhibited), 2);
R::storeAll(array($m1, $m2, $m3));
list($m1, $m2, $m3) = array_values(R::findAll('museum', ' ORDER BY thename ASC'));
asrt(count($m1->sharedPainting), 1);
asrt(count($m2->sharedPainting), 2);
asrt(count($m3->sharedPainting), 1);
$p3 = reset($m1->sharedPainting);
asrt(count($p3->ownExhibited), 2);
$paintings = $m2->sharedPainting;
foreach ($paintings as $painting) {
if ($painting->name === 'painting2') {
pass();
$paintingX = $painting;
}
}
unset($m2->sharedPainting[$paintingX->id]);
R::store($m2);
$m2 = R::load('museum', $m2->id);
asrt(count($m2->sharedPainting), 1);
$left = reset($m2->sharedPainting);
asrt($left->name, 'painting3');
asrt(count($m2->ownExhibited), 1);
$exhibition = reset($m2->ownExhibited);
asrt($exhibition->from, '2014-07-03');
asrt($exhibition->til, '2014-10-02');
}