コード例 #1
0
 function runHydrate($i)
 {
     $books = \Model_Book::find('all', array('limit' => 5, 'where' => array(array('price', '>', $i))));
     foreach ($books as $book) {
     }
     Cache::delete_all();
 }
コード例 #2
0
 function init()
 {
     parent::init();
     // We must select books which are either never been borrowed or have been returned
     $f = $this->join('library_borrowing.library_book_id', null, 'left')->addField('is_returned')->system(true);
     // Now that our relation is defined we can add custom condition with the OR clause.
     $this->addCondition($this->dsql()->orExpr()->where($f, 'is', null)->where($f, '1'));
 }
コード例 #3
0
ファイル: files.php プロジェクト: xXLXx/ddc
 public function action_index()
 {
     $data['files'] = Model_File::find('all');
     $books = Model_Book::find('all');
     $book_arr = array();
     foreach ($books as $value) {
         array_push($book_arr, $value->book_url);
         array_push($book_arr, $value->cover_photo);
     }
     sort($book_arr);
     $data['books'] = $book_arr;
     $this->template->title = "Files";
     $this->template->content = View::forge('site/files/index', $data);
 }
コード例 #4
0
ファイル: books.php プロジェクト: xXLXx/ddc
 public function get_by_user($user_id)
 {
     $user = Model_User::find($user_id);
     $success = false;
     if (!$user) {
         return $this->error(['Cannot find user.']);
     }
     $data = null;
     if ($user->isRoleTeacher()) {
         $data = Model_Book::find('all', ['related' => ['subject' => ['where' => ['user_id' => $user->id]]]]);
     } else {
         if ($user->isRoleStudent()) {
             $data = Model_Book::find('all', ['related' => ['student_course' => ['where' => ['user_id' => $user->id]]]]);
         }
     }
     if ($data) {
         $success = true;
     }
     return $this->response(['data' => $data, 'success' => $success]);
 }
コード例 #5
0
ファイル: bookapi.php プロジェクト: j16sdiz/ctyc-library
 private function create_books($value, $copy, $start_copy)
 {
     $books = array();
     for ($c = $start_copy; $c < $start_copy + $copy; $c++) {
         $book = new Model_Book();
         $book->values($value);
         $book->copy = $c;
         $book->save();
         array_push($books, $book->as_array());
     }
     return $books;
 }
コード例 #6
0
ファイル: book.php プロジェクト: xXLXx/ddc
 public function action_delete($id = null)
 {
     $where = ['id' => $id];
     if (Model_User::is_current_user('teacher')) {
         $where['subject.user_id'] = Auth::get('id');
     }
     if ($book = Model_Book::find('first', ['where' => $where, 'related' => ['subject']])) {
         $book->delete();
         Session::set_flash('success', e('Deleted book #' . $id));
     } else {
         Session::set_flash('error', e('Could not delete book #' . $id));
     }
     Response::redirect('site/book');
 }
コード例 #7
0
ファイル: modeljoin.php プロジェクト: atk4/atk4-tests
 function init()
 {
     parent::init();
     $this->a = $this->join('author');
     $this->a->addField('email');
     $this->a->addField('birth')->type('date');
 }