本文整理汇总了PHP中RedBeanPHP\QueryWriter\AQueryWriter::clearRenames方法的典型用法代码示例。如果您正苦于以下问题:PHP AQueryWriter::clearRenames方法的具体用法?PHP AQueryWriter::clearRenames怎么用?PHP AQueryWriter::clearRenames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\QueryWriter\AQueryWriter
的用法示例。
在下文中一共展示了AQueryWriter::clearRenames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIssueWithDriverReturnID
/**
* Test whether a duplicate bean in the list isnt saved.
* This was an issue with Postgres while testing the threeway tables.
* Postgres returned the ID as a string while other drivers returned
* a numeric value causing different outcome in array_diff when
* calculating the shared additions.
*
* @return void
*/
public function testIssueWithDriverReturnID()
{
AQueryWriter::clearRenames();
R::nuke();
$book = R::dispense('book');
$page = R::dispense('page');
$book->sharedPageList[] = $page;
R::store($book);
asrt(R::count('page'), 1);
$book = $book->fresh();
$book->sharedPageList[] = $page;
R::store($book);
//don't save the duplicate bean!
asrt(R::count('page'), 1);
$book = $book->fresh();
$page->item = 2;
//even if we change a property ?
$book->sharedPageList[] = $page;
R::store($book);
foreach ($book->sharedPageList as $listItem) {
asrt(is_string($listItem->id), TRUE);
}
//same test but for own-list
R::nuke();
$book = R::dispense('book');
$page = R::dispense('page');
$book->ownPageList[] = $page;
R::store($book);
asrt(R::count('page'), 1);
$book = $book->fresh();
$book->ownPageList[] = $page;
R::store($book);
//don't save the duplicate bean!
asrt(R::count('page'), 1);
$book = $book->fresh();
$book->ownPageList[] = $page;
$page->item = 3;
R::store($book);
//don't save the duplicate bean!
asrt(R::count('page'), 1);
foreach ($book->ownPageList as $listItem) {
asrt(is_string($listItem->id), TRUE);
}
AQueryWriter::clearRenames();
}
示例2: 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();
}
示例3: testIssue378
//.........这里部分代码省略.........
$book = $book->fresh();
$book->via('garbage')->nothing;
asrt(count($book->sharedPageList), 1);
//yet another
$book = R::dispense('magazine');
$book->ownAdList[] = R::dispense('ad');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->ownAdList;
asrt(count($book->sharedPageList), 1);
$book = R::dispense('folder');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->sharedItemList[] = R::dispense('item');
asrt(count($book->sharedPageList), 1);
$book = R::dispense('folder2');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->sharedItemList[] = R::dispense('item');
$book->via('garbage')->sharedItemList[] = R::dispense('item');
asrt(count($book->sharedPageList), 1);
$book = R::dispense('folder3');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->item = R::dispense('item');
asrt(count($book->sharedPageList), 1);
$book = R::dispense('folder3');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->item = 'test';
asrt(count($book->sharedPageList), 1);
//yet another
$book = R::dispense('leaflet');
$book->title = 'leaflet';
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->title;
asrt(count($book->sharedPageList), 1);
//yet another
$book = R::dispense('paper');
$book->author = R::dispense('author');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->author;
asrt(count($book->sharedPageList), 1);
$book = R::dispense('paper2');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('garbage')->author;
asrt(count($book->sharedPageList), 1);
//yet another one
$book = R::dispense('archive');
$book->sharedItem[] = R::dispense('item');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
unset($book->via('garbage')->sharedItem);
asrt(count($book->sharedPageList), 1);
//theoretic cases
$book = R::dispense('guide');
$book->sharedItem[] = R::dispense('item');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('relation')->countShared('item');
$book->via('relation')->countShared('item');
asrt(count($book->sharedPageList), 1);
$book = R::dispense('catalogue');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('relation')->countShared('item');
$book->via('relation')->countShared('item');
asrt(count($book->sharedPageList), 1);
$book = R::dispense('tabloid');
$book->ownItemList[] = R::dispense('item');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('relation')->countOwn('item');
$book->via('relation')->countOwn('item');
asrt(count($book->sharedPageList), 1);
$book = R::dispense('booklet');
$book->ownItemList[] = R::dispense('item');
$book->sharedPage[] = R::dispense('page');
R::store($book);
$book = $book->fresh();
$book->via('relation')->countOwn('item');
$book->via('relation')->countOwn('item');
asrt(count($book->sharedPageList), 1);
AQueryWriter::clearRenames();
}
示例4: testUniqueInspect
/**
* Test whether unique constraints are properly created using
* reflection.
*
* @return void
*/
public function testUniqueInspect()
{
$writer = R::getWriter();
R::nuke();
$book = R::dispense('book');
$category = R::dispense('category');
$book->sharedCategory[] = $category;
R::store($book);
asrt(count(get_uniques_for_type('book_category')), 1);
asrt(are_cols_in_unique('book_category', array('book_id', 'category_id')), TRUE);
R::nuke();
$book = R::dispense('book');
$category = R::dispense('category');
$book->via('library')->sharedCategory[] = $category;
R::store($book);
asrt(count(get_uniques_for_type('book_category')), 0);
asrt(are_cols_in_unique('book_category', array('book_id', 'category_id')), FALSE);
asrt(count(get_uniques_for_type('library')), 1);
asrt(are_cols_in_unique('library', array('book_id', 'category_id')), TRUE);
AQueryWriter::clearRenames();
R::nuke();
$book = R::dispense('book');
$category = R::dispense('category');
$book->sharedCategory[] = $category;
R::store($book);
asrt(count(get_uniques_for_type('book_category')), 1);
asrt(are_cols_in_unique('book_category', array('book_id', 'category_id')), TRUE);
asrt(count(get_uniques_for_type('library')), 0);
asrt(are_cols_in_unique('library', array('book_id', 'category_id')), FALSE);
R::nuke();
$book = R::dispense('book');
$book2 = R::dispense('book');
$book->sharedBook[] = $book2;
R::store($book);
asrt(count(get_uniques_for_type('book_book')), 1);
asrt(are_cols_in_unique('book_book', array('book_id', 'book2_id')), TRUE);
try {
$result = R::getWriter()->addUniqueConstraint('nonexistant', array('a', 'b'));
} catch (\Exception $e) {
print_r($e);
exit;
}
pass();
//dont crash!
asrt($result, FALSE);
}