本文整理汇总了PHP中RedBean_OODBBean::setFlagKeyedExport方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBean_OODBBean::setFlagKeyedExport方法的具体用法?PHP RedBean_OODBBean::setFlagKeyedExport怎么用?PHP RedBean_OODBBean::setFlagKeyedExport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBean_OODBBean
的用法示例。
在下文中一共展示了RedBean_OODBBean::setFlagKeyedExport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExportWithFilters
/**
* Test exporting with filters.
*
* @return void
*/
public function ExportWithFilters()
{
testpack('Export with filters');
$book = R::dispense('book');
$pages = R::dispense('page', 2);
$texts = R::dispense('text', 2);
$images = R::dispense('image', 2);
$author = R::dispense('author');
$pub = R::dispense('publisher');
$bookmarks = R::dispense('bookmark', 2);
$pages[0]->ownText = array($texts[0]);
$pages[0]->ownImage = array($images[0]);
$pages[1]->ownText = array($texts[1]);
$pages[1]->ownImage = array($images[1]);
$pages[0]->sharedBookmark[] = $bookmarks[0];
$pages[1]->sharedBookmark[] = $bookmarks[1];
$bookmarks[0]->ownNote[] = R::dispense('note')->setAttr('text', 'a note');
$bookmarks[1]->ownNote[] = R::dispense('note')->setAttr('text', 'a note');
$book->ownPage = $pages;
$book->author = $author;
$author->publisher = $pub;
$bookID = R::store($book);
R::$duplicationManager->setTables(R::$writer->getTables());
$objects = R::exportAll(array($book), TRUE, array());
asrt(isset($objects[0]['ownPage']), TRUE);
asrt(count($objects[0]['ownPage']), 2);
asrt(isset($objects[0]['author']), TRUE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
asrt(isset($objects[0]['ownPage'][0]['ownImage']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownImage']), 1);
$objects = R::exportAll(array($book), TRUE, array('page', 'author', 'text', 'image'));
asrt(isset($objects[0]['ownPage']), TRUE);
asrt(count($objects[0]['ownPage']), 2);
asrt(isset($objects[0]['author']), TRUE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
asrt(isset($objects[0]['ownPage'][0]['ownImage']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownImage']), 1);
$objects = R::exportAll(array($book), TRUE, 'author');
asrt(isset($objects[0]['ownPage']), FALSE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), FALSE);
$objects = R::exportAll(array($book), TRUE, array('page'));
asrt(isset($objects[0]['author']), FALSE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), FALSE);
$objects = R::exportAll(array($book), TRUE, array('page', 'text'));
asrt(isset($objects[0]['author']), FALSE);
asrt(isset($objects[0]['ownPage']), TRUE);
asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
asrt(isset($objects[0]['ownPage'][0]['ownImage']), FALSE);
$objects = R::exportAll(array($book), TRUE, array('none'));
asrt(isset($objects[0]['author']), FALSE);
asrt(isset($objects[0]['ownPage']), FALSE);
$texts = R::find('text');
R::preload($texts, 'page,*.book,*.author');
$objects = R::exportAll($texts, TRUE);
asrt(isset($objects[0]['page']['book']['author']['publisher']), TRUE);
asrt(isset($objects[0]['page']['sharedBookmark']), FALSE);
$texts = R::find('text');
R::preload($texts, array('page', 'page.sharedBookmark' => 'bookmark'));
$objects = R::exportAll($texts, TRUE);
asrt(isset($objects[0]['page']['book']['author']['publisher']), TRUE);
asrt(isset($objects[0]['page']['sharedBookmark']), TRUE);
asrt(isset($objects[0]['page']['sharedBookmark'][0]['ownNote']), FALSE);
$texts = R::find('text');
R::preload($texts, array('page', 'page.sharedBookmark' => 'bookmark', 'page.sharedBookmark.ownNote' => 'note'));
$objects = R::exportAll($texts, TRUE);
asrt(isset($objects[0]['page']['book']['author']['publisher']), TRUE);
asrt(isset($objects[0]['page']['sharedBookmark']), TRUE);
asrt(isset($objects[0]['page']['sharedBookmark'][0]['ownNote']), TRUE);
R::$duplicationManager->setCacheTables(FALSE);
testpack('Keyless export');
$book = R::load('book', $bookID);
$book->ownPage;
$export = $book->export();
asrt(isset($export['ownPage'][0]), TRUE);
RedBean_OODBBean::setFlagKeyedExport(TRUE);
$export = $book->export();
asrt(isset($export['ownPage'][1]), TRUE);
RedBean_OODBBean::setFlagKeyedExport(FALSE);
$export = $book->export();
asrt(isset($export['ownPage'][0]), TRUE);
}