本文整理汇总了PHP中Books类的典型用法代码示例。如果您正苦于以下问题:PHP Books类的具体用法?PHP Books怎么用?PHP Books使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Books类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
$userid = Auth::user()->userid;
// return Input::get("");exit();
$book = new Books();
$book->title = Input::get('title');
$book->description = Input::get('description');
$book->category = Input::get('genre');
$book->sub_category = "none";
$book->author = Input::get('author');
$book->condition = Input::get('cond');
$book->location = Input::get('loc');
$book->cover = Input::get('image');
$book->snippet = "none";
$book->language = Input::get('lang');
$book->popularity = "none";
$book->quantity = Input::get('quantity');
$book->expected_price = Input::get('rate');
$book->purpose = Input::get('purpose');
$book->added_by = $userid;
//The USERID
$book->save();
//Add Book to Personal Info of the User
$tn = $userid . "_books";
DB::table($tn)->insert(array('title' => Input::get('title'), 'author' => Input::get("author"), 'condition' => Input::get('cond'), 'location' => Input::get('loc'), 'language' => Input::get('lang'), 'quantity' => Input::get('quantity'), 'expected_price' => Input::get('rate'), 'avlb' => 1));
}
示例2: actionAdd
public function actionAdd()
{
Yii::app()->getClientScript()->registerCoreScript('jquery');
Yii::app()->getClientScript()->registerCoreScript('jquery.ui');
$cs = Yii::app()->clientScript;
$cs->registerCssFile('/js/datepicker/css/' . 'datepicker.css');
$cs->registerScriptFile('/js/' . 'books.js');
//
$book = new Books();
$command = Yii::app()->db->createCommand();
if (isset($_POST['Books'])) {
$book->attributes = $_POST['Books'];
if ($book->validate()) {
$book->save();
if (isset($_POST['add_auth']) && !empty($_POST['add_auth'])) {
$criteria = new CDbCriteria();
$criteria->compare('lastname', $_POST['add_auth']);
$add_author = Authors::model()->find($criteria);
//If author exists
if (!empty($add_author)) {
//insert link book-author to link table
$command->insert('lt_books_authors', array('author_id' => $add_author->id, 'book_id' => $book->id));
}
}
$this->actionIndex();
return true;
}
}
$this->render('edit', array('model' => $book));
}
示例3: showBook
function showBook()
{
$model = new Books();
$comment_section = new CommentsController();
$data = $model->getBookData();
include 'view/libro/libro.php';
$comment_section->showComments();
}
示例4: actionSearch
public function actionSearch()
{
$model = Books::model();
$params = array('result' => $model->searchPhrase($_POST['search_field']));
$this->render('search', $params);
//echo '<pre>'; print_r($_POST); echo'</pre>';
}
示例5: getOne
function getOne() {
$query = 'SELECT * FROM `genre` WHERE `name`=' . Database::escape($this->genre_name);
$data = Database::sql2row($query);
if (!isset($data['name']))
return;
$this->data['genres'][$data['id']] = array(
'name' => $data['name'],
'id' => $data['id'],
'id_parent' => $data['id_parent'],
'title' => $data['title'],
'books_count' => $data['books_count']
);
if (!$data['id_parent']) {
$this->data['genres'][$data['id']]['subgenres'] = $this->getAll($data['id']);
return;
}
$query = 'SELECT `id_book` FROM `book_genre` BG JOIN `book` B ON B.id = BG.id_book WHERE BG.id_genre = ' . $data['id'] . ' ORDER BY B.mark DESC LIMIT 20';
$bids = Database::sql2array($query, 'id_book');
$books = Books::getByIdsLoaded(array_keys($bids));
Books::LoadBookPersons(array_keys($bids));
foreach ($books as $book) {
$book = Books::getById($book->id);
list($aid, $aname) = $book->getAuthor(1, 1, 1); // именно наш автор, если их там много
$this->data['genres'][$data['id']]['books'][] = array('id' => $book->id,
'cover' => $book->getCover(),
'title' => $book->getTitle(true),
'author' => $aname,
'author_id' => $aid,
'lastSave' => $book->data['modify_time']);
}
}
示例6: run
public function run()
{
DB::table('books')->delete();
Books::create(array('bname' => 'talha', 'bauthor' => 'talha1', 'bedition' => 'Eight', 'p_url' => 'ajed5hrgt4y', 'created_at' => new DateTime(), 'updated_at' => new DateTime()));
DB::table('books')->insert(['bname' => 'talha', 'bauthor' => 'talha2', 'bedition' => 'ten', 'p_url' => 'ajed53y56hy', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
DB::table('books')->insert(['bname' => 'talha', 'bauthor' => 'talha3', 'bedition' => 'nine', 'p_url' => 'ajed5hy', 'created_at' => new DateTime(), 'updated_at' => new DateTime()]);
}
示例7: actionIndex
public function actionIndex()
{
$book_model = Books::model();
$authors_model = Authors::model();
$params = array('book_model' => $book_model, 'authors_model' => $authors_model);
$this->render('report', $params);
}
示例8: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$student = Student::find($id);
if ($student == NULL) {
throw new Exception('Invalid Student ID');
}
$student->year = (int) substr($student->year, 2, 4);
$student_category = StudentCategories::find($student->category);
$student->category = $student_category->category;
$student_branch = Branch::find($student->branch);
$student->branch = $student_branch->branch;
if ($student->rejected == 1) {
unset($student->approved);
unset($student->books_issued);
$student->rejected = (bool) $student->rejected;
return $student;
}
if ($student->approved == 0) {
unset($student->rejected);
unset($student->books_issued);
$student->approved = (bool) $student->approved;
return $student;
}
unset($student->rejected);
unset($student->approved);
$student_issued_books = Logs::select('book_issue_id', 'issued_at')->where('student_id', '=', $id)->orderBy('time_stamp', 'desc')->take($student->books_issued)->get();
foreach ($student_issued_books as $issued_book) {
$issue = Issue::find($issued_book->book_issue_id);
$book = Books::find($issue->book_id);
$issued_book->name = $book->title;
$issued_book->issued_at = date('d-M', $issued_book->issued_at);
}
$student->issued_books = $student_issued_books;
return $student;
}
示例9: getRoutes
static function getRoutes()
{
$routes = [['get:books', function () {
return (new Books())->index();
}], ['get:books\\/(?<id>\\d+)', function ($params) {
return (new Books())->show($params['id']);
}], ['post:books', function () {
return (new Books())->store(Books::filterData($_REQUEST));
}], ['put:books\\/(?<id>\\d+)', function ($params) {
return (new Books())->update($params['id'], Books::filterData($_REQUEST));
}], ['delete:books\\/(?<id>\\d+)', function ($params) {
return (new Books())->destroy($params['id']);
}], ['get:libs', function () {
return (new Libraries())->index();
}], ['get:libs\\/(?<id>\\d+)', function ($params) {
return (new Libraries())->show($params['id']);
}], ['post:libs', function () {
return (new Libraries())->store(Libraries::filterData($_REQUEST));
}], ['put:libs\\/(?<id>\\d+)', function ($params) {
return (new Libraries())->update($params['id'], Libraries::filterData($_REQUEST));
}], ['delete:libs\\/(?<id>\\d+)', function ($params) {
return (new Libraries())->destroy($params['id']);
}]];
return $routes;
}
示例10: commitEdit
public function commitEdit()
{
$id = Input::get('id');
// validate the info, create rules for the inputs
$rules = array('title' => 'required', 'author' => 'required');
// run the validation rules on the inputs from the form
$validator = Validator::make(Input::all(), $rules);
// if the validator fails, redirect back to the form
if ($validator->fails()) {
return Redirect::to('edit/' . $id)->withErrors($validator)->withInput();
// send back the input (not the password) so that we can repopulate the form
} else {
//return 'book added';
// create our user data for the authentication
$bookdata = array('title' => Input::get('title'), 'author' => Input::get('author'));
//return $id;
// update the data
if ($Book = Books::where('id', '=', $id)->update($bookdata)) {
// update successful!
return Redirect::to('books')->with('message', 'Book info updated');
} else {
// validation not successful, send back to form
return Redirect::to('edit/' . $id)->with('message', 'Book info editing failed');
}
}
}
示例11: actionSearch
public function actionSearch()
{
if (!isset($_GET['val'])) {
$_GET['val'] = NULL;
}
echo Books::getList(NULL, $_GET['val']);
}
示例12: getBooksFromFiltr
private function getBooksFromFiltr($arg)
{
//прием аргументов фильтрации, снова повторюсь сори что без валидации
$authors = $arg['authors'];
$genre = $arg['genre'];
$from_year = $arg['from_year'];
$to_year = $arg['to_year'];
//все индификаторы книг что прошли фильтр по автору и по жанрам
$book_author = BookAuthor::model()->with('books')->findAllByAttributes($authors);
$book_gerne = BookGenre::model()->with('books')->findAllByAttributes($genre);
foreach ($book_author as $class) {
$flag[$class->bid] = true;
//методом флажок - выясню есть ли в другом масиве теже bid
}
foreach ($book_gerne as $class) {
if ($flag[$class->bid]) {
$bids[] = $class->bid;
}
//если была создана ячека флажка, то значит что первый фильтр bid прошел
}
//выборка всех книг по фильтрованым индификаторам
$books = Books::model()->findAllByAttributes(array('bid' => $bids), 'year>=' . $from_year . ' AND year<=' . $to_year);
//хочу свормировать красивый масив без ячеек, которые сотворил yii
$result = array();
$i = 0;
foreach ($books as $book) {
$result[$i]['authors'] = $this->getAuthorsFromBid($book->bid);
$result[$i]['genres'] = $this->getGenresFromBid($book->bid);
$result[$i]['book']['bid'] = $book->bid;
$result[$i]['book']['name'] = $book->name;
$result[$i]['book']['year'] = $book->year;
$i = $i + 1;
}
return $result;
}
示例13: actionSample
public function actionSample()
{
$json = file_get_contents('E:\\xampp\\htdocs\\books\\protected\\data\\data.json');
$arr = json_decode($json, true);
foreach ($arr["Books"] as $item) {
$model = new Books();
$model->book_description = $item['Description'];
$model->book_name = $item['Title'];
$model->book_image = $item['Image'];
$model->book_author = 'Anonymous';
$model->book_publisher = 'It Ebook';
$model->book_year = 2009;
$model->created_at = time();
$model->updated_at = time();
$model->status = 1;
$model->save(FALSE);
}
}
示例14: actionAbout
public function actionAbout($id)
{
$book = Books::model()->findByPk($id);
if (!empty($book)) {
$comments = BooksComments::model()->findAll(array('condition' => 'book_id = :bookId', 'params' => array(':bookId' => $book->id), 'order' => 'id DESC', 'limit' => '10'));
$this->render('about', array('book' => $book, 'comments' => $comments));
} else {
$this->redirect(array('index/index'));
}
}
示例15: loadModel
public function loadModel($id = null, $new = false)
{
if ($this->_book === null) {
if ($new) {
return $this->_book = new Books();
}
$this->_book = Books::model()->findByPk($_GET['id']);
if ($this->_book === null) {
throw new CHttpException(404, 'Sorry! There is no such book.');
}
}
return $this->_book;
}