当前位置: 首页>>代码示例>>PHP>>正文


PHP Facade::count方法代码示例

本文整理汇总了PHP中RedBeanPHP\Facade::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::count方法的具体用法?PHP Facade::count怎么用?PHP Facade::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedBeanPHP\Facade的用法示例。


在下文中一共展示了Facade::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBasicTraversal

 /**
  * Tests basic traversal.
  *
  * @return void
  */
 public function testBasicTraversal()
 {
     R::nuke();
     $pageA = R::dispense('page')->setAttr('title', 'a');
     $pageB = R::dispense('page')->setAttr('title', 'b');
     $pageC = R::dispense('page')->setAttr('title', 'c');
     $pageD = R::dispense('page')->setAttr('title', 'd');
     $pageE = R::dispense('page')->setAttr('title', 'e');
     $pageF = R::dispense('page')->setAttr('title', 'f');
     $pageG = R::dispense('page')->setAttr('title', 'g');
     $pageH = R::dispense('page')->setAttr('title', 'h');
     $pageA->ownPage = array($pageB, $pageC);
     $pageB->ownPage = array($pageD);
     $pageC->ownPage = array($pageE, $pageF);
     $pageD->ownPage = array($pageG);
     $pageF->ownPage = array($pageH);
     R::store($pageA);
     $pageA = $pageA->fresh();
     //also tests non-existant column handling by count().
     asrt(R::count('page', ' price = ? ', array('5')), 0);
     asrt(R::count('tag', ' title = ? ', array('new')), 0);
     $pageA->traverse('ownPageList', function ($bean) {
         $bean->price = 5;
     });
     R::store($pageA);
     asrt(R::count('page', ' price = ? ', array('5')), 7);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:32,代码来源:Traverse.php

示例2: testTrash

 /**
  * Tests the handling of trashed beans in frozen mode.
  * Are the lists unset etc?
  *
  * @return void
  */
 public function testTrash()
 {
     R::nuke();
     $book = R::dispense('book');
     $book->xownPageList[] = R::dispense('page');
     $book->sharedTagList[] = R::dispense('tag');
     R::store($book);
     $book = $book->fresh();
     R::freeze(TRUE);
     $book->xownPageList = array();
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('page'), 0);
     $book->xownPageList[] = R::dispense('page');
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('page'), 1);
     $book->xownPageList;
     $book->sharedTagList;
     R::trash($book);
     asrt(R::count('book'), 0);
     asrt(R::count('page'), 0);
     asrt(R::count('tag'), 1);
     asrt(R::count('book_tag'), 0);
     R::freeze(FALSE);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:32,代码来源:Frozen.php

示例3: setParams

 /**
  * @param string $DBTable
  * @param int $startPage
  * @param int $maxResults
  */
 public function setParams($DBTable, $maxResults, $startPage)
 {
     $this->DBTable = $DBTable;
     $this->maxResults = $maxResults;
     $this->startPage = $startPage;
     $this->storedNumber = Facade::count($this->DBTable);
 }
开发者ID:AsemKhatib,项目名称:MyPoll-OOP-PHP-Poll-system,代码行数:12,代码来源:pagenation.class.php

示例4: testQuickTrash

 /**
  * Tests quick trash method: R::trash( type, id ).
  *
  * @return void
  */
 public function testQuickTrash()
 {
     R::nuke();
     $bean = R::dispense('bean');
     $id = R::store($bean);
     asrt(R::count('bean'), 1);
     R::trash('bean', $id);
     asrt(R::count('bean'), 0);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:14,代码来源:Facade.php

示例5: testCategoryDeletion

 public function testCategoryDeletion()
 {
     Scripts::CreateCategory('Berlin');
     $this->byLinkText('System Settings')->click();
     $this->byLinkText('Categories')->click();
     $this->byName('delete-ideas')->click();
     $this->byName('delete-category')->click();
     $numberOfCategories = RedBean::count('categories');
     $this->assertEquals($numberOfCategories, 1);
 }
开发者ID:MindWorp,项目名称:phpback,代码行数:10,代码来源:AdminPanelTest.php

示例6: testKWConflicts

 /**
  * Test whether we can use foreign keys with keywords.
  *
  * @return void
  */
 public function testKWConflicts()
 {
     R::nuke();
     $metrics = R::dispense('metrics');
     $constraint = R::dispense('constraint');
     $constraint->xownMetrics[] = $metrics;
     R::store($constraint);
     asrt(1, R::count('metrics'));
     R::trash($constraint);
     asrt(0, R::count('metrics'));
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:16,代码来源:Foreignkeys.php

示例7: init

 /**
  * @brief inits the class
  */
 public static function init()
 {
     session_start();
     if (R::count("user") < 1) {
         self::register(["username" => "admin", "password" => "admin"]);
     }
     if ($_SESSION["is_loggedin"]) {
         self::$is_loggedin = true;
         self::$user = $_SESSION["user"];
     }
 }
开发者ID:profenter,项目名称:redbeanphptools,代码行数:14,代码来源:user.class.php

示例8: testExportIssue

 /**
  * In the past it was not possible to export beans
  * like 'feed' (Model_Feed).
  *
  * @return void
  */
 public function testExportIssue()
 {
     R::nuke();
     $feed = R::dispense('feed');
     $feed->post = array('first', 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = R::load('feed', $feed->id);
     $feed->post[] = 'third';
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second","third"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     asrt($feed->post[2], 'third');
     //now the catch: can we use export?
     //PHP Fatal error:  Call to a member function export() on a non-object
     $feeds = R::exportAll(R::find('feed'));
     asrt(is_array($feeds), TRUE);
     $feed = reset($feeds);
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
     //can we also dup()?
     $feedOne = R::findOne('feed');
     R::store(R::dup($feedOne));
     asrt(R::count('feed'), 2);
     //can we delete?
     R::trash($feedOne);
     asrt(R::count('feed'), 1);
     $feedTwo = R::findOne('feed');
     $feed = $feedTwo->export();
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:52,代码来源:Issue408.php

示例9: testNoLoad

 /**
  * Tests no-load modifier for lists.
  * 
  * @return void
  */
 public function testNoLoad()
 {
     $book = R::dispense(array('_type' => 'book', 'title' => 'Book of Lorem Ipsum', 'ownPage' => array(array('_type' => 'page', 'content' => 'Lorem Ipsum')), 'sharedTag' => array(array('_type' => 'tag', 'label' => 'testing'))));
     R::store($book);
     $book = $book->fresh();
     asrt(R::count('book'), 1);
     asrt(count($book->ownPage), 1);
     //now try with no-load
     $book = $book->fresh();
     asrt(count($book->noLoad()->ownPage), 0);
     asrt(count($book->noLoad()->sharedTag), 0);
     //now try to add with no-load
     $book = $book->fresh();
     $book->noLoad()->xownPageList[] = R::dispense('page');
     $book->noLoad()->sharedTagList[] = R::dispense('tag');
     R::store($book);
     $book = $book->fresh();
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
     //no-load overrides with and withCondition
     $book = $book->fresh();
     asrt(count($book->with(' invalid sql ')->noLoad()->ownPage), 0);
     asrt(count($book->withCondition(' invalid sql ')->noLoad()->sharedTag), 0);
     //no-load overrides all and alias
     $book = $book->fresh();
     asrt(count($book->all()->noLoad()->ownPage), 0);
     asrt(count($book->alias('nothing')->noLoad()->sharedTag), 0);
     //no-load gets cleared
     $book = $book->fresh();
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
     //We cant clear with no-load accidentally?
     $book = $book->fresh();
     $book->noLoad()->ownPage = array();
     $book->noLoad()->sharedTagList = array();
     R::store($book);
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
     //No-load does not have effect if list is already cached
     $book = $book->fresh();
     $book->ownPage;
     $book->sharedTag;
     asrt(count($book->ownPage), 2);
     asrt(count($book->sharedTagList), 2);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:50,代码来源:With.php

示例10: testDupPortionOfATree

 /**
  * Test whether we can duplicate part of a tree
  * without infinite loops.
  *
  * @return void
  */
 public function testDupPortionOfATree()
 {
     R::nuke();
     $article = R::dispense('article');
     $article->name = 'article 1';
     list($article2, $article3) = R::dispense('article', 2);
     $article2->name = 'article 2';
     $article3->name = 'article 3';
     list($article4, $article5) = R::dispense('article', 2);
     $article4->name = 'article 4';
     $article5->name = 'article 5';
     list($article6, $article7) = R::dispense('article', 2);
     $article6->name = 'article 6';
     $article7->name = 'article 7';
     $article3->xownArticleList[] = $article7;
     $article4->xownArticleList[] = $article6;
     $article2->xownArticleList = array($article5, $article4);
     $article->xownArticleList = array($article2, $article3);
     R::store($article);
     asrt(R::count('article'), 7);
     $article2 = $article2->fresh();
     $dupArticle2 = R::duplicate($article2);
     $dupArticle2->name = 'article 2b';
     $dupBeans = $dupArticle2->xownArticleList;
     foreach ($dupBeans as $dupBean) {
         $list[] = $dupBean->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 4,article 5');
     foreach ($dupBeans as $dupBean) {
         if ($dupBean->name === 'article 4') {
             $dup4 = $dupBean;
         }
     }
     asrt(isset($dup4), TRUE);
     $dupBeans = $dup4->xownArticleList;
     foreach ($dupBeans as $dupBean) {
         asrt($dupBean->name, 'article 6');
     }
     //so we have extracted part of the tree, can we store it?
     $id = R::store($dupArticle2);
     asrt($id > 0, TRUE);
     asrt(R::count('article'), 11);
     $originalArticle = $article->fresh();
     asrt($originalArticle->name, 'article 1');
     $subArticles = $originalArticle->xownArticleList;
     $list = array();
     foreach ($subArticles as $subArticle) {
         $list[] = $subArticle->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 2,article 2b,article 3');
     foreach ($subArticles as $subArticle) {
         if ($subArticle->name === 'article 2') {
             $sub2 = $subArticle;
         }
         if ($subArticle->name === 'article 3') {
             $sub3 = $subArticle;
         }
     }
     $subArticles = $sub2->xownArticleList;
     $list = array();
     foreach ($subArticles as $subArticle) {
         $list[] = $subArticle->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 4,article 5');
     $subArticles = $sub3->xownArticleList;
     $list = array();
     foreach ($subArticles as $subArticle) {
         $list[] = $subArticle->name;
     }
     sort($list);
     $listStr = implode(',', $list);
     asrt($listStr, 'article 7');
     $subArticles = $sub2->xownArticleList;
     foreach ($subArticles as $subArticle) {
         if ($subArticle->name === 'article 4') {
             $sub4 = $subArticle;
         }
         if ($subArticle->name === 'article 5') {
             $sub5 = $subArticle;
         }
     }
     asrt(count($sub4->xownArticleList), 1);
     $subBeans = $sub4->xownArticleList;
     $subBean = reset($subBeans);
     asrt($subBean->name, 'article 6');
     asrt(count($sub5->xownArticleList), 0);
     $dupArticle2 = $dupArticle2->fresh();
     $subArticles = $dupArticle2->xownArticleList;
//.........这里部分代码省略.........
开发者ID:gabordemooij,项目名称:redbean,代码行数:101,代码来源:Dup.php

示例11: testConditionsAndAliases

 /**
  * Test conditions and aliases.
  */
 public function testConditionsAndAliases()
 {
     R::nuke();
     $author = R::xdispense(AUTHOR);
     $author->name = 'Mr. Quill';
     $book = R::xdispense(BOOK);
     $book->title = 'Good Stories';
     $book2 = R::xdispense(BOOK);
     $book2->title = 'Good Stories 2';
     $friend = R::xdispense(FRIEND);
     $friend->name = 'Muse';
     $publisher = R::xdispense(PUBLISHER);
     $publisher->name = 'Good Books';
     $author->{BOOKLIST} = array($book, $book2);
     $author->{FRIENDLIST}[] = $friend;
     $author->{PUBLISHER} = $publisher;
     $coAuthor = R::xdispense(AUTHOR);
     $coAuthor->name = 'Xavier';
     $book2->{COAUTHOR} = $coAuthor;
     R::store($author);
     $author = $author->fresh();
     asrt(R::count(AUTHOR), 2);
     //Can we use with and withCondition?
     asrt(count($author->{BOOKLIST}), 2);
     asrt(count($author->with(' LIMIT 1 ')->{BOOKLIST}), 1);
     asrt(count($author->withCondition(' title LIKE ? ', array('%2%'))->{BOOKLIST}), 1);
     //Can we use an alias?
     $book2 = $book2->fresh();
     asrt($book2->fetchAs(AUTHOR)->{COAUTHOR}->name, 'Xavier');
     $coAuthor = $book2->fetchAs(AUTHOR)->{COAUTHOR}->fresh();
     asrt(count($coAuthor->alias(COAUTHOR)->{BOOKLIST}), 1);
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:35,代码来源:Prefixes.php

示例12: testDependency4

 /**
  * Tests dependencies (variation).
  *
  * @return void
  */
 public function testDependency4()
 {
     R::nuke();
     $can = $this->createBeanInCan(TRUE);
     R::store($can);
     R::trash($can);
     $can = $this->createCanForBean();
     asrt(R::count('bean'), 1);
     R::trash($can);
     asrt(R::count('bean'), 0);
     $can = $this->createBeanInCan(TRUE);
     R::store($can);
     R::trash($can);
     $can = $this->createCanForBean();
     asrt(R::count('bean'), 1);
     R::trash($can);
     asrt(R::count('bean'), 0);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:23,代码来源:Foreignkeys.php

示例13: testMultiDeleteUpdate

 /**
  * Test trashAll().
  */
 public function testMultiDeleteUpdate()
 {
     testpack('test multi delete and multi update');
     $beans = R::dispenseLabels('bean', array('a', 'b'));
     $ids = R::storeAll($beans);
     asrt((int) R::count('bean'), 2);
     R::trashAll(R::batch('bean', $ids));
     asrt((int) R::count('bean'), 0);
     testpack('test assocManager check');
     $rb = new OODB(R::getWriter());
     try {
         $rb->getAssociationManager();
         fail();
     } catch (RedException $e) {
         pass();
     }
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:20,代码来源:Misc.php

示例14: testEmptyBean

 /**
  * Tests whether we can store an empty bean.
  * An empty bean has no properties, only ID. Normally we would
  * skip the ID field in an INSERT, this test forces the driver
  * to specify a value for the ID field. Different writers have to
  * use different values: Mysql uses NULL to insert a new auto-generated ID,
  * while Postgres has to use DEFAULT.
  */
 public function testEmptyBean()
 {
     testpack('Test Empty Bean Storage.');
     R::nuke();
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 1);
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 2);
     //also test in frozen mode
     R::freeze(TRUE);
     $bean = R::dispense('emptybean');
     $id = R::store($bean);
     asrt($id > 0, TRUE);
     asrt(R::count('emptybean'), 3);
     R::freeze(FALSE);
 }
开发者ID:skullyframework,项目名称:skully,代码行数:28,代码来源:Database.php

示例15: testDontAddUniqueConstraintForChilledBeanTypes

 /**
  * Test whether we cannot add unique constraints on chilled tables,
  * otherwise you cannot avoid this from happening when adding beans to the
  * shared list :) -- this is almost a theoretical issue however we want it
  * to work according to specifications!
  *
  * @return void
  */
 public function testDontAddUniqueConstraintForChilledBeanTypes()
 {
     R::nuke();
     $person = R::dispense('person');
     $role = R::dispense('role');
     $person->sharedRole[] = $role;
     R::store($person);
     $person->sharedRole[] = R::dispense('role');
     R::store($person);
     $bean = R::getRedBean()->dispense('person_role');
     $bean->personId = $person->id;
     $bean->roleId = $role->id;
     try {
         R::store($bean);
         fail();
     } catch (\Exception $e) {
         pass();
     }
     asrt(R::count('person_role'), 2);
     R::nuke();
     $link = R::getRedBean()->dispense('person_role');
     $person = R::dispense('person');
     $role = R::dispense('role');
     $link->person = $person;
     $link->role = $role;
     R::store($link);
     R::freeze(array('person_role'));
     $person->sharedRole[] = R::dispense('role');
     R::store($person);
     $bean = R::getRedBean()->dispense('person_role');
     $bean->personId = $person->id;
     $bean->roleId = $role->id;
     try {
         R::store($bean);
         pass();
     } catch (\Exception $e) {
         fail();
     }
     asrt(R::count('person_role'), 3);
     R::freeze(array());
     //set freeze to FALSE and clear CHILL LIST!
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:50,代码来源:Chill.php


注:本文中的RedBeanPHP\Facade::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。