本文整理匯總了PHP中think\Model::count方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::count方法的具體用法?PHP Model::count怎麽用?PHP Model::count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類think\Model
的用法示例。
在下文中一共展示了Model::count方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
public function index()
{
$model = new Model('Comment');
$count = $model->count();
$page = new Page($count, 30);
$list = $model->order('commentId DESC')->limit($page->firstRow . ',' . $page->listRows)->select();
$this->assign('list', $list);
$this->assign('page', $page->show());
$this->display();
}
示例2: count
/**
* 重寫count方法 以支持associate和sqlOptions
* @param array|string $options count(['hy'=>true]) | count('id')
*/
public function count($options)
{
if (!$this->isCallHyFunc($options)) {
return parent::count($options);
}
return $this->select(array_merge(is_array($options) ? $options : array(), array('count' => true)));
}
示例3: testMagicMethods
public function testMagicMethods()
{
$model = new Model('user', $this->getConfig());
$model->data("first=a&last=z");
$model->username = 'test';
$data = ['first' => 'a', 'last' => 'z', 'username' => 'test'];
$this->assertEquals($data, $model->data());
$this->assertEquals('a', $model->first);
$this->assertTrue(isset($model->last));
unset($model->username);
$this->assertTrue(!isset($model->username));
$this->assertEquals(2, $model->count());
$info = $model->getByUsername('test');
$this->assertEquals(1, $info['id']);
$id = $model->getFieldByUsername('test', 'id');
$this->assertEquals(1, $id);
$id = $model->getFieldByUsername('test', 'id');
$this->assertEquals(1, $id);
}