Refactoring again

This commit is contained in:
Sébastien Lucas 2014-01-08 16:54:11 +01:00
parent 50ae991e95
commit a6b52887ff
2 changed files with 15 additions and 11 deletions

View file

@ -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;
}

View file

@ -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;