예제 #1
0
 private function getAuthorsFromBid($bid)
 {
     //все класы авторов, что привязаны к индификатору книги
     $book_author = BookAuthor::model()->with('books')->findAllByAttributes(array('bid' => $bid));
     $aids = array();
     foreach ($book_author as $class) {
         $aids[] = $class->aid;
     }
     $authors = Authors::model()->findAllByAttributes(array('aid' => $aids));
     //формирую красивый масив для результата функции
     $result = array();
     if (!empty($authors)) {
         foreach ($authors as $author) {
             $result['name'][] = $author->name;
             $result['surname'][] = $author->surname;
         }
     }
     return $result;
 }
예제 #2
0
파일: Book.php 프로젝트: stpncpe/cbdbx
 public function removeAuthor($author_id)
 {
     $pk = array('book_id' => $this->id, 'author_id' => $author_id);
     BookAuthor::model()->deleteByPk($pk);
 }