| @@ 22-52 (lines=31) @@ | ||
| 19 | * @param boolean $publish If it needs to be publish |
|
| 20 | * @return object With "all" database content data |
|
| 21 | */ |
|
| 22 | public function getAllContent($page = null, $perPage = null, $publish = true){ |
|
| 23 | $now = date('Y-m-d H:i:s'); |
|
| 24 | $params = array(); |
|
| 25 | ||
| 26 | $this->db->select("c.*") |
|
| 27 | ->from("content AS c") |
|
| 28 | // ->join("user AS u", "c.author = u.id") |
|
| 29 | ->where("c.`deleted` IS NULL"); |
|
| 30 | ||
| 31 | if($publish){ |
|
| 32 | $this->db->andWhere("c.published <= ?"); |
|
| 33 | $params[] = $now; |
|
| 34 | } |
|
| 35 | ||
| 36 | $this->db->orderBy('c.published DESC, c.created DESC'); |
|
| 37 | ||
| 38 | /*if($perPage){ |
|
| 39 | $this->db->limit($perPage); |
|
| 40 | ||
| 41 | if($page){ |
|
| 42 | $offset = $this->getOffset($perPage, $page); |
|
| 43 | $this->db->offset($offset); |
|
| 44 | } |
|
| 45 | }*/ |
|
| 46 | ||
| 47 | $this->db->execute($params); |
|
| 48 | ||
| 49 | $this->db->setFetchModeClass(__CLASS__); |
|
| 50 | return $this->db->fetchAll(); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Get "all" content of one type from database (limit by per page) |
|
| 55 | * |
|
| @@ 62-92 (lines=31) @@ | ||
| 59 | * @param int $perPage Contents per page |
|
| 60 | * @return object With "all" database content data |
|
| 61 | */ |
|
| 62 | public function getAllContentOfType($type, $page = null, $perPage = null, $publish = true){ |
|
| 63 | $now = date('Y-m-d H:i:s'); |
|
| 64 | $params = array($type); |
|
| 65 | ||
| 66 | $this->db->select("c.*") |
|
| 67 | ->from("content AS c") |
|
| 68 | // ->join("user AS u", "c.author = u.id") |
|
| 69 | ->where("c.`type` = ?") |
|
| 70 | ->andWhere("c.`deleted` IS NULL"); |
|
| 71 | ||
| 72 | if($publish){ |
|
| 73 | $this->db->andWhere("c.published <= ?"); |
|
| 74 | $params[] = $now; |
|
| 75 | } |
|
| 76 | ||
| 77 | $this->db->orderBy('c.published DESC, c.created DESC'); |
|
| 78 | ||
| 79 | /*if($perPage){ |
|
| 80 | $this->db->limit($perPage); |
|
| 81 | ||
| 82 | if($page){ |
|
| 83 | $offset = $this->getOffset($perPage, $page); |
|
| 84 | $this->db->offset($offset); |
|
| 85 | } |
|
| 86 | }*/ |
|
| 87 | ||
| 88 | $this->db->execute($params); |
|
| 89 | ||
| 90 | $this->db->setFetchModeClass(__CLASS__); |
|
| 91 | return $this->db->fetchAll(); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * Get "all" content of one tag and one type from database |
|