本文整理汇总了PHP中Book::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::model方法的具体用法?PHP Book::model怎么用?PHP Book::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
// $criteria = new CDbCriteria ();
// $criteria->order = 'id desc';
// $newest_book = Book::model()->find($criteria);
//sach moi
$criteria = new CDbCriteria();
$criteria->order = 'id desc';
$criteria->limit = 9;
$list_book = Book::model()->findAll($criteria);
//sach moi nhat
$criteria = new CDbCriteria(array('order' => 'id DESC', 'limit' => '1'));
// $dataProvider=new CActiveDataProvider('Book',array(
// // 'pagination'=>array(
// // 'pageSize'=>Yii::app()->params['booksPerPage'],
// // ),
// 'criteria'=>$criteria,
// ));
$dataProvider = Book::model()->find($criteria);
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
// $this->render('index');
$this->render('index', array('dataProvider' => $dataProvider, 'list_book' => $list_book));
}
示例2: init
public function init()
{
parent::init();
// Create new field in your users table for store dashboard preference
// Set table name, user ID field name, user preference field name
$this->setTableParams('dashboard_page', 'user_id', 'title');
// set array of portlets
$this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos críticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4))));
//set content BEFORE dashboard
$this->setContentBefore();
// uncomment the following to apply jQuery UI theme
// from protected/components/assets/themes folder
$this->applyTheme('ui-lightness');
// uncomment the following to change columns count
//$this->setColumns(4);
// uncomment the following to enable autosave
$this->setAutosave(true);
// uncomment the following to disable dashboard header
$this->setShowHeaders(false);
// uncomment the following to enable context menu and add needed items
/*
$this->menu = array(
array('label' => 'Index', 'url' => array('index')),
);
*/
}
示例3: actionIndex
public function actionIndex()
{
$num = 3;
$array = Book::model()->findAll('id<:num', array(':num' => $num));
//echo $array->title;
$this->render('index', array('array' => $array));
}
示例4: actionBookList
public function actionBookList()
{
if ($_POST["start"]) {
$criteria = new CDbCriteria();
$criteria->condition = "Start BETWEEN :start AND :finish AND UserID = :userid";
$criteria->params = array(':start' => date("Y-m-d", strtotime($_POST["start"])), ':finish' => date("Y-m-d", strtotime($_POST["fin"])), ':userid' => Yii::app()->user->ID);
$criteria->order = 'Start ASC';
$model = Book::model()->findAll($criteria);
set_time_limit(600);
# mPDF
$pdf = Yii::app()->ePdf->mpdf('', 'A4', '', '', '', '', '', '', '', '', 'P');
$pdf->writeHTMLfooter = false;
$pdf->writeHTMLheader = false;
$pdf->DeflMargin = 15;
$pdf->DefrMargin = 15;
$pdf->tMargin = 15;
$pdf->bMargin = 15;
$pdf->w = 297;
//manually set width
$pdf->h = 209.8;
//manually set height
# render (full page)
$pdf->WriteHTML($this->renderPartial('_booklist', array('model' => $model), true));
# Outputs ready PDF
$pdf->Output('ListaReservas_' . date("d/m/Y") . '.pdf', 'D');
} else {
$this->render('selector');
}
}
示例5: runJoinSearch
public function runJoinSearch($i)
{
$book = Book::model()->find(array('alias' => 'b', 'condition' => 'b.title = :t', 'params' => [':t' => 'Hello' . $i], 'with' => ['author']));
// $book = $this->em->createQuery(
// 'SELECT b, a FROM Book b JOIN b.author a WHERE b.title = ?1'
// )->setParameter(1, 'Hello' . $i)
// ->setMaxResults(1)
// ->getResult();
}
示例6: actionIndex
public function actionIndex()
{
$b = new Book();
$b->title = 'Master and Margarita';
$b->author = 'M.Bylgakov';
$b->year = '1905';
//$b->save(false);
$id = $_GET['id'];
$model = Book::model()->search();
$this->render('index', array('model' => $model));
}
示例7: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
$model = array();
$model['publishers'] = count(Publishing::model()->findAll());
$model['authors'] = count(Author::model()->findAll());
$model['books'] = count(Book::model()->findAll());
$model['pictures'] = count(Picture::model()->findAll());
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index', ['model' => $model]);
}
示例8: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->order = 'id desc';
// $list_book = Book::model()->findAll($criteria);
$list_book = new CActiveDataProvider('Book', array('pagination' => array('pageSize' => '9'), 'criteria' => $criteria));
//sach moi nhat
$criteria = new CDbCriteria(array('order' => 'id DESC', 'limit' => '1'));
$dataProvider = Book::model()->find($criteria);
$this->render('index', array('dataProvider' => $dataProvider, 'list_book' => $list_book));
}
示例9: getBooksAll
public static function getBooksAll()
{
$criteria = new CDbCriteria([]);
$pages = new CPagination(Book::model()->count($criteria));
$pages->pageSize = 4;
$pages->applyLimit($criteria);
$model = Book::model()->findAll($criteria);
$books = array();
foreach ($model as $item) {
$books[] = self::getBookAll($item->id);
}
return $books;
}
示例10: RunReport
private function RunReport()
{
$criteria = new CDbCriteria();
$criteria = array('select' => 'count(grade_id) as num_grade, grade_id', 'with' => array('grade'), 'group' => 'grade_id');
$books = Book::model()->findAll($criteria);
// initialize report
$report = array('data' => array(array('label' => 'Comic Books by Grade', 'data' => array(), 'bars' => array('show' => true, 'align' => 'center'))), 'options' => array('legend' => array('show' => false)), 'htmlOptions' => array('style' => 'width:200px;height:200px;'));
foreach ($books as $book) {
$report['data'][0]['data'][] = array($book->grade_id, $book->num_grade);
$report['options']['xaxis']['ticks'][] = array($book->grade_id, $book->grade->name);
}
return $report;
}
示例11: actionLend
public function actionLend($book_id, $user_id)
{
$model = Book::model()->findByPk($book_id);
if ($model === null) {
throw new CHttpException(404, 'The requested book does not exist.');
}
$request = Request::model()->find('book_id=:book_id AND requester_id=:user_id', array(':book_id' => $book_id, ':user_id' => $user_id));
if ($request === null) {
throw new CHttpException(404, 'The request does not exist.');
}
$request->delete();
$model->borrower_id = $user_id;
$model->save();
$this->redirect(array('book/index'));
}
示例12: _normalizeContent
private function _normalizeContent($arrContent)
{
if (isset($arrContent['book_name'])) {
$book = Book::model()->find('LCASE(book_name) LIKE LCASE(:name)', array('name' => '%' . $arrContent['book_name'] . '%'));
if ($book == null) {
$book = Book::model()->find('LCASE(book_name) LIKE LCASE(:name)', array('name' => $arrContent['name']));
}
if (isset($book) && !empty($book)) {
$arrContent['book_link_id'] = $book->link_id;
}
}
if (isset($arrContent['book_name'])) {
unset($arrContent['book_name']);
}
return $arrContent;
}
示例13: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new BorrowBook();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if ($_POST['BorrowBook']) {
$model->attributes = $_POST['BorrowBook'];
$model->validate();
if (isset($_POST['BorrowBook']) and $_POST['BorrowBook']['student_admission_no'] != NULL and $_POST['BorrowBook']['subject'] != NULL and $_POST['BorrowBook']['book_name'] != NULL and $_POST['BorrowBook']['issue_date'] != NULL and $_POST['BorrowBook']['due_date'] != NULL) {
$model->attributes = $_POST['BorrowBook'];
if ($model->validate()) {
$student = Students::model()->findByAttributes(array('admission_no' => $_POST['BorrowBook']['student_admission_no'], 'is_deleted' => 0, 'is_active' => 1));
if ($student == NULL) {
Yii::app()->user->setFlash('errorMessage', UserModule::t("Enter valid student admission number! <br/> The entered admission_no is deleted or inactive"));
$this->redirect(array('create', 'id' => $_POST['BorrowBook']['student_admission_no']));
}
$status = Book::model()->findByAttributes(array('id' => $_POST['BorrowBook']['book_name']));
if ($status != NULL) {
if ($status->copy == 0) {
$this->redirect(array('/library/BorrowBook/listbook/'));
} else {
if ($model->issue_date) {
//$currdate=$model->issue_date;
//$model->due_date =date('Y-m-d',strtotime("+1 months", strtotime($currdate)));
$model->issue_date = date('Y-m-d', strtotime($model->issue_date));
}
$model->due_date = date('Y-m-d', strtotime($model->due_date));
$model->status = 'C';
$model->book_id = $status->id;
$model->subject = $status->subject;
$model->student_id = $student->id;
$model->book_name = $status->title;
if ($model->save()) {
//echo $status->copy; exit;
$status->saveAttributes(array('status' => 'S', 'copy_taken' => $status->copy_taken + 1, 'copy' => $status->copy - 1));
$this->redirect(array('view', 'id' => $model->id));
}
}
} else {
$this->redirect(array('/library/BorrowBook/error/'));
}
}
}
}
$this->render('create', array('model' => $model));
}
示例14: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($id)
{
$model = new ReturnBook();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['ReturnBook'])) {
$model->attributes = $_POST['ReturnBook'];
if ($model->return_date) {
$model->return_date = date('Y-m-d', strtotime($model->return_date));
}
if ($model->issue_date) {
$model->issue_date = date('Y-m-d', strtotime($model->issue_date));
}
if ($_POST['ReturnBook']['borrow_book_id']) {
$borrow = BorrowBook::model()->findByAttributes(array('id' => $_POST['ReturnBook']['borrow_book_id']));
}
$status = Book::model()->findByAttributes(array('title' => $borrow->book_name));
//echo $model->borrow_book_id; exit;
$model->book_id = $status->id;
if ($model->save()) {
//$borrow=BorrowBook::model()->findByAttributes(array('id'=>$model->borrow_book_id,'student_id'=>$id));
$user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
//updating borrowbook table
// echo count($borrow);
$borrow->status = 'R';
// $borrow->validate();
//var_dump($borrow->getErrors());
// exit;
$borrow->save();
$status->status = 'R';
$status->copy = $status->copy + 1;
if ($status->copy_taken != '0') {
$status->copy_taken = $status->copy_taken - 1;
}
$status->save();
//if($model->return_date >= $borrow->due_date)
// {
// User::sendMail($user->email,'Due date expired','<html><body>Dear '.$profile->first_name.' '.$profile->last_name.' ,
// Your due date has expired. And you have to pay the fine.</body></html>', 'Dear '.$profile->first_name.' '.$profile->last_name.' ,
// Your due date has expired. And you have to pay the fine');
// }
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model, 'bookid' => $_POST['BookID']));
}
示例15: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new Giohang;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Giohang']))
{
$idbook = intval($_POST['Giohang']["id_book"]);
$namebook = intval($_POST['Giohang']["name_book"]);
$cost = intval($_POST['Giohang']["cost"]);
$status = intval($_POST['Giohang']["status"]);
$number = intval($_POST['Giohang']["number"]);
$iduser = Yii::app()->user->id;
// update so luong sach
$book=Book::model()->findByPk($idbook);
// Book::model()->loadModel($idbook);
if ($book->slcon > $number) {
$book->slcon = $book->slcon - $number;
$book->save();
$model->id_book = $idbook;
$model->name_book = $namebook;
$model->cost = $cost;
$model->status = $status;
$model->number = $number;
$model->id_user = $iduser;
$model->attributes=$_POST['Giohang'];
if($model->save())
// $this->redirect(array('view','id'=>$model->id));
$this->redirect(array('//site/index'));
}
}
// $this->render('create',array(
// 'model'=>$model,
// ));
}