示例#1
0
 /**
  * TODO: Function Description
  * @param Var Description
  */
 public function LoadSections($book, $chapter)
 {
     if (!is_numeric($book) && !is_numeric($chapter)) {
         return false;
     }
     $query = "SELECT COUNT(*)\n\t\t\tFROM information_schema.tables \n\t\t\tWHERE table_schema = DATABASE()\n\t\t\tAND table_name = 's_" . $this->Bible->Table . "';";
     $has_sections = $this->app['db']->fetchColumn($query);
     if ($has_sections) {
         $sections = array();
         $book = Utilities::zerofill($book, 2);
         $chapter = Utilities::zerofill($chapter);
         $query = "SELECT * FROM s_" . $this->Bible->Table . " WHERE 1=1";
         $query .= " AND sv LIKE '" . $book . $chapter . "%'";
         $result = $this->app['db']->fetchAll($query);
         foreach ($result as $res) {
             $section = new Section();
             $section->Id = $res['sid'];
             $section->Title = $res['title'];
             $section->StartVerse = substr($res['sv'], -2);
             $section->EndVerse = substr($res['ev'], -2);
             $sections[$res['sv']] = $section;
         }
         return $sections;
     }
     return null;
 }
 /**
  * TODO: Function Description
  * @param Var Description
  */
 public static function getBook($app, $book, $bible = null)
 {
     $params = array();
     $query = "SELECT * FROM books WHERE 1=1";
     if (is_numeric($book)) {
         $where = " AND b = :book1";
         $params['book1'] = $book;
     } else {
         $where = " AND abbreviation=:book2";
         $params['book2'] = $book;
         $where .= " OR dutch LIKE :book3";
         $params['book3'] = $book . "%";
         $where .= " OR english LIKE :book4";
         $params['book4'] = $book . "%";
     }
     $stmt = $app['db']->executeQuery($query . $where, $params);
     $stmt->execute();
     $result = $stmt->fetch(\PDO::FETCH_ASSOC);
     if (empty($result)) {
         \OpenBible\Utilities::output("Het boek '" . ucfirst($book) . "' bestaat niet.");
         return false;
     } else {
         $b = new Book($app, $bible);
         $b->Id = $result['b'];
         $b->Abbr = $result['abbreviation'];
         $b->Names = array('english' => $result['english'], 'dutch' => $result['dutch']);
         $b->CountChapters();
         return $b;
     }
 }