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;
|
||||
}
|
||||
|
|
15
data.php
15
data.php
|
@ -76,7 +76,7 @@ class Data extends Base {
|
|||
}
|
||||
|
||||
finfo_close($finfo);
|
||||
|
||||
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -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