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


PHP NewsModel::setdown方法代码示例

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


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

示例1: get

 function get()
 {
     $this->f3 = \Base::instance();
     $this->f3->set('AUTOLOAD', $this->f3->get('AUTOLOAD') . ';app/cortex/');
     $this->f3->set('QUIET', false);
     $this->test = new \Test();
     $dbs = array('sql' => new \DB\SQL('mysql:host=localhost;port=3306;dbname=fatfree', 'fatfree', ''));
     foreach ($dbs as $type => $db) {
         $this->f3->set('DB', $db);
         $this->currentType = $type;
         $this->roundTime = microtime(TRUE) - \Base::instance()->get('timer');
         \AuthorModel::setdown();
         \TagModel::setdown();
         \NewsModel::setdown();
         \AuthorModel::setup();
         \TagModel::setup();
         \NewsModel::setup();
         $this->insert_tags();
         $this->insert_authors();
         $this->insert_news();
         $this->insert_news();
         $news = new \NewsModel();
         // reset timer
         $this->getTime();
         //            $result = $news->find(null,array('limit'=>5000));
         //            $this->test->message($this->getTime()." hydrate 5000 records");
         //            unset($news,$result);
         //            $news = new \NewsModel();
         //            $result = $news->find(null,array('limit' => 1000));
         //            $result[0]->author->name;
         //            $this->test->message($this->getTime()." hydrate 1000 records with 1 relation fixed size");
         //			unset($result);
         $result = $news->find(null, array('limit' => 1000));
         $result[0]->tags2[0];
         $this->test->message($this->getTime() . " hydrate 1000 records with 1 relation random size");
         //            $this->test->message($this->getTime()." hydrate 1000 records with 2 relations random size");
         //            $result = $news->find('author = 11');
         //            $this->test->message($this->getTime()." find news from a specific author(11): ".count($result).' news found');
         //            $result = $news->has('author',array('mail LIKE ?','%.co.uk%'))->find();
         //            $this->test->message($this->getTime()." find news with has condition on author: ".count($result).' news found');
         //        var_dump($this->f3->get('DB')->log());
     }
     $this->f3->set('results', $this->test->results());
 }
开发者ID:ikkez,项目名称:f3-cortex,代码行数:44,代码来源:cortex_benchmark.php

示例2: run

 function run($db, $type)
 {
     $test = new \Test();
     // clear existing data
     \AuthorModel::setdown();
     \TagModel::setdown();
     \NewsModel::setdown();
     \ProfileModel::setdown();
     // setup models
     \AuthorModel::setup();
     \TagModel::setup();
     \NewsModel::setup();
     \ProfileModel::setup();
     // setup Author
     ///////////////////////////////////
     $author_id = array();
     $author = new \AuthorModel();
     $ac = $author::resolveConfiguration();
     $author_pk = is_int(strpos($type, 'sql')) ? $ac['primary'] : '_id';
     $author->name = 'Johnny English';
     $author->save();
     $author_id[] = $author->_id;
     $author->reset();
     $author->name = 'Ridley Scott';
     $author->save();
     $author_id[] = $author->_id;
     $author->reset();
     $author->name = 'James T. Kirk';
     $author->save();
     $author_id[] = $author->_id;
     $author->reset();
     $allauthors = $author->find()->castAll();
     $allauthors = $this->getResult($allauthors);
     $test->expect(json_encode($allauthors) == '[{"name":"Johnny English"},{"name":"Ridley Scott"},{"name":"James T. Kirk"}]', $type . ': all AuthorModel items created');
     // setup Tags
     ///////////////////////////////////
     $tag_id = array();
     $tag = new \TagModel();
     $tc = $tag::resolveConfiguration();
     $tag_pk = is_int(strpos($type, 'sql')) ? $tc['primary'] : '_id';
     $tag->title = 'Web Design';
     $tag->save();
     $tag_id[] = $tag->_id;
     $tag->reset();
     $tag->title = 'Responsive';
     $tag->save();
     $tag_id[] = $tag->_id;
     $tag->reset();
     $tag->title = 'Usability';
     $tag->save();
     $tag_id[] = $tag->_id;
     $tag->reset();
     $allTags = $this->getResult($tag->find());
     $test->expect(json_encode($allTags) == '[{"title":"Web Design"},{"title":"Responsive"},{"title":"Usability"}]', $type . ': all TagModel items created');
     // setup News
     ///////////////////////////////////
     $news_id = array();
     $news = new \NewsModel();
     $nc = $news::resolveConfiguration();
     $news_pk = is_int(strpos($type, 'sql')) ? $nc['primary'] : '_id';
     $news->title = 'Responsive Images';
     $news->text = 'Lorem Ipsun';
     $news->save();
     $news_id[] = $news->_id;
     $news->reset();
     $news->title = 'CSS3 Showcase';
     $news->text = 'News Text 2';
     $news->save();
     $news_id[] = $news->_id;
     $news->reset();
     $news->title = 'Touchable Interfaces';
     $news->text = 'Lorem Foo';
     $news->save();
     $news_id[] = $news->_id;
     $news->reset();
     $allnews = $this->getResult($news->find(null, array('order' => 'title')));
     $test->expect(count($allnews) == 3 && $allnews[0]['title'] == 'CSS3 Showcase' && $allnews[1]['title'] == 'Responsive Images' && $allnews[2]['title'] == 'Touchable Interfaces', $type . ': all NewsModel items created');
     // belongs-to author relation
     ///////////////////////////////////
     $author->load();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $news->author = $author;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect($news->author->name == 'Johnny English', $type . ': belongs-to-one: author relation created');
     $news->author = NULL;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect(empty($news->author), $type . ': belongs-to-one: author relation released');
     $news->author = $author->_id;
     $news->save();
     $news->reset();
     $news->load(array($news_pk . ' = ?', $news_id[0]));
     $test->expect($news->author->name == 'Johnny English', $type . ': belongs-to-one: relation created by raw id');
     // belongs-to-many tag relation
     ///////////////////////////////////
     $tag1 = new \TagModel();
     $tag1->load(array($tag_pk . ' = ?', $tag_id[0]));
//.........这里部分代码省略.........
开发者ID:ikkez,项目名称:f3-cortex,代码行数:101,代码来源:test_relation.php


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