forked from Public/pics
Database: start reworking the DBA to work with PDO
This commit is contained in:
@@ -28,7 +28,7 @@ class AssetIterator extends Asset
|
||||
|
||||
public function next()
|
||||
{
|
||||
$row = $this->db->fetch_assoc($this->res_assets);
|
||||
$row = $this->db->fetchAssoc($this->res_assets);
|
||||
|
||||
// No more rows?
|
||||
if (!$row)
|
||||
@@ -36,7 +36,7 @@ class AssetIterator extends Asset
|
||||
|
||||
// Looks up metadata.
|
||||
$row['meta'] = [];
|
||||
while ($meta = $this->db->fetch_assoc($this->res_meta))
|
||||
while ($meta = $this->db->fetchAssoc($this->res_meta))
|
||||
{
|
||||
if ($meta['id_asset'] != $row['id_asset'])
|
||||
continue;
|
||||
@@ -49,7 +49,7 @@ class AssetIterator extends Asset
|
||||
|
||||
// Looks up thumbnails.
|
||||
$row['thumbnails'] = [];
|
||||
while ($thumbs = $this->db->fetch_assoc($this->res_thumbs))
|
||||
while ($thumbs = $this->db->fetchAssoc($this->res_thumbs))
|
||||
{
|
||||
if ($thumbs['id_asset'] != $row['id_asset'])
|
||||
continue;
|
||||
@@ -78,13 +78,13 @@ class AssetIterator extends Asset
|
||||
if (!$this->res_assets)
|
||||
return;
|
||||
|
||||
$this->db->free_result($this->res_assets);
|
||||
$this->db->free($this->res_assets);
|
||||
$this->res_assets = null;
|
||||
}
|
||||
|
||||
public function num()
|
||||
{
|
||||
return $this->db->num_rows($this->res_assets);
|
||||
return $this->db->rowCount($this->res_assets);
|
||||
}
|
||||
|
||||
public static function all()
|
||||
@@ -114,9 +114,9 @@ class AssetIterator extends Asset
|
||||
{
|
||||
$params['mime_type'] = $options['mime_type'];
|
||||
if (is_array($options['mime_type']))
|
||||
$where[] = 'a.mimetype IN({array_string:mime_type})';
|
||||
$where[] = 'a.mimetype IN(@mime_type)';
|
||||
else
|
||||
$where[] = 'a.mimetype = {string:mime_type}';
|
||||
$where[] = 'a.mimetype = :mime_type';
|
||||
}
|
||||
if (isset($options['id_user_uploaded']))
|
||||
{
|
||||
@@ -129,7 +129,17 @@ class AssetIterator extends Asset
|
||||
$where[] = 'id_asset IN(
|
||||
SELECT l.id_asset
|
||||
FROM assets_tags AS l
|
||||
WHERE l.id_tag = {int:id_tag})';
|
||||
WHERE l.id_tag = :id_tag)';
|
||||
}
|
||||
elseif (isset($options['tag']))
|
||||
{
|
||||
$params['tag'] = $options['tag'];
|
||||
$where[] = 'id_asset IN(
|
||||
SELECT l.id_asset
|
||||
FROM assets_tags AS l
|
||||
INNER JOIN tags AS t
|
||||
ON l.id_tag = t.id_tag
|
||||
WHERE t.slug = :tag)';
|
||||
}
|
||||
|
||||
// Make it valid SQL.
|
||||
@@ -145,7 +155,7 @@ class AssetIterator extends Asset
|
||||
FROM assets AS a
|
||||
WHERE ' . $where . '
|
||||
ORDER BY ' . $order . (!empty($params['limit']) ? '
|
||||
LIMIT {int:offset}, {int:limit}' : ''),
|
||||
LIMIT :offset, :limit' : ''),
|
||||
$params);
|
||||
|
||||
// Get a resource object for the asset meta.
|
||||
@@ -165,9 +175,9 @@ class AssetIterator extends Asset
|
||||
SELECT id_asset, filename,
|
||||
CONCAT(
|
||||
width,
|
||||
{string:x},
|
||||
:x,
|
||||
height,
|
||||
IF(mode != {string:empty}, CONCAT({string:_}, mode), {string:empty})
|
||||
IF(mode != :empty1, CONCAT(:_, mode), :empty2)
|
||||
) AS selector
|
||||
FROM assets_thumbs
|
||||
WHERE id_asset IN(
|
||||
@@ -177,7 +187,8 @@ class AssetIterator extends Asset
|
||||
)
|
||||
ORDER BY id_asset',
|
||||
$params + [
|
||||
'empty' => '',
|
||||
'empty1' => '',
|
||||
'empty2' => '',
|
||||
'x' => 'x',
|
||||
'_' => '_',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user