本文整理匯總了PHP中app\models\Books::jgridBooks方法的典型用法代碼示例。如果您正苦於以下問題:PHP Books::jgridBooks方法的具體用法?PHP Books::jgridBooks怎麽用?PHP Books::jgridBooks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Books
的用法示例。
在下文中一共展示了Books::jgridBooks方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: count
function test_jgridBooks()
{
//OK
$get = ['page' => 1, 'limit' => 10, 'sort_column' => 'created_date', 'sort_order' => 'desc', 'filters' => ''];
$resp = Books::jgridBooks($get);
$this->assertInstanceOf('\\stdClass', $resp);
$this->assertEquals($resp->page, 1);
$this->assertEquals($resp->records, count($this->dataset['books']));
$this->assertEquals(count($resp->rows), $resp->records);
$book1 = $resp->rows[0];
$this->assertEquals(true, is_array($book1));
$this->assertEquals($this->dataset['books'][0]['book_guid'], $book1['id']);
$this->assertEquals((new \DateTime($this->dataset['books'][0]['created_date']))->format('d-m-Y'), $book1['cell'][0]);
//TODO: more stuff?
// empty get, test defaults
unset($get['page']);
$resp = Books::jgridBooks([]);
$this->assertInstanceOf('\\stdClass', $resp);
$this->assertEquals($resp->page, 1);
$this->assertEquals($resp->records, count($this->dataset['books']));
}
示例2: actionBooks
/**
* return list of books in jqgrid format
* @return string json
*/
public function actionBooks()
{
$data = ['page' => \Yii::$app->request->get('page'), 'limit' => \Yii::$app->request->get('rows'), 'filters' => \Yii::$app->request->get('filters'), 'sort_column' => \Yii::$app->request->get('sidx'), 'sort_order' => \Yii::$app->request->get('sord')];
//TODO: currently on store in cookies
//\Yii::$app->session->set('jqgrid.page', $data['page']);
return Json::encode(Books::jgridBooks($data));
}