public function listContents() { $sql[] = "SELECT *"; $sql[] = " FROM jos_content"; $sql[] = " WHERE state = 1"; return $this->daoTemplate->queryForList(implode("\n", $sql), new ContentRowMapper(), null); }
public function save(StaticContentDto $content) { $sql[] = "INSERT INTO static_content"; $sql[] = " SET id = :id,"; $sql[] = " body = :body,"; $sql[] = " date_modification = :date_modification"; $sql[] = " ON DUPLICATE KEY UPDATE body=VALUES(body)"; $params[':id'] = $content->id; $params[':body'] = $content->body; $params[':date_modification'] = time(); $result = $this->daoTemplate->queryForUpdate(implode("\n", $sql), $params); return $result; }
public function listAll($state = ContentDto::STATE_ONLINE, $start = 0, $nbContent = 0, $home = false) { $params = array(); $sql[] = "SELECT content.*, creator.name as name_creator, modificator.name as name_modificator FROM content"; $sql[] = " LEFT JOIN user AS creator ON (content.id_user_creation = creator.id)"; $sql[] = " LEFT JOIN user AS modificator ON (content.id_user_modification = modificator.id)"; $where = array(); if ($state != ContentDto::STATE_ALL) { $where[] = "content.state = :state"; $params[':state'] = $state; } if ($home == true) { $where[] = "home = 1 and edito=0"; } if (sizeof($where) > 0) { $sql[] = " WHERE " . implode(" AND ", $where); } $sql[] = " ORDER BY date_publication DESC"; if ($nbContent > 0) { $sql[] = " LIMIT {$start}, {$nbContent}"; } return $this->daoTemplate->queryForList(implode("\n", $sql), new ContentRowMapper(), $params); }