Refactoring again
This commit is contained in:
parent
50ae991e95
commit
a6b52887ff
11
book.php
11
book.php
|
@ -192,16 +192,7 @@ class Book extends Base {
|
|||
public function getDatas ()
|
||||
{
|
||||
if (is_null ($this->datas)) {
|
||||
$this->datas = array ();
|
||||
|
||||
$result = parent::getDb ()->prepare('select id, format, name
|
||||
from data where book = ?');
|
||||
$result->execute (array ($this->id));
|
||||
|
||||
while ($post = $result->fetchObject ())
|
||||
{
|
||||
array_push ($this->datas, new Data ($post, $this));
|
||||
}
|
||||
$this->datas = Data::getDataByBook ($this);
|
||||
}
|
||||
return $this->datas;
|
||||
}
|
||||
|
|
13
data.php
13
data.php
|
@ -124,6 +124,19 @@ class Data extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
public static function getDataByBook ($book) {
|
||||
$out = array ();
|
||||
$result = parent::getDb ()->prepare('select id, format, name
|
||||
from data where book = ?');
|
||||
$result->execute (array ($book->id));
|
||||
|
||||
while ($post = $result->fetchObject ())
|
||||
{
|
||||
array_push ($out, new Data ($post, $book));
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
|
||||
{
|
||||
global $config;
|
||||
|
|
Loading…
Reference in a new issue