An example would be:
Within the admin area of the site after creating the object call $g->admin(); which would prevent the live='1' part of the query from being called within the sql query.
public function admin()
{
$this->admin = 1;
}
public function getGallery($gallery)
{
if (!isset($this->admin))
{
$live = "AND g.live='1' AND gi.live='1'";
}
if (!$stmt = $this->db->prepare("SELECT gi.id, gi.caption, gi.image, gi.thumb FROM `galleryImages` gi
INNER JOIN `gallery` g WHERE gi.delete!='1' AND g.delete!='1' ".$live." AND g.page=? OR g.id=? ORDER BY gi.order ASC"))
{
throw new mException($this->db->error, $this->db->errno);
}
$stmt->bind_param('si', $gallery, $gallery);
if (!$stmt->execute())
{
throw new mException($stmt->error, $stmt->errno);
}
$stmt->bind_result($this->id, $this->caption, $this->image, $this->thumb);
$entry = array();
while ($stmt->fetch())
{
$entry[] = $this->objectToArray();
}
return $entry;
}
Or would it be more suited to duplicate getGallery into another method which would only be used within the admin.
The code is pretty rough just needed a quick example.