/** * Renvoie la liste des villes * les met en cache aussi ! */ function cities($lang = 'fr') { $prefix = 'geo_' . $lang . '_'; $this->db->cache_on(); $q = $this->db->select($prefix . 'city.id,' . $prefix . 'city.name_city, ' . $prefix . 'city.cp, ' . $prefix . 'province.name_province')->from($prefix . 'city')->join($prefix . 'province', $prefix . 'city.id_province = ' . $prefix . 'province.id', 'left')->get(); $city_global = $q->result(); $cities = array(); foreach ($city_global as $key => $city) { $cities[$city->id] = $city; } $this->db->cache_off(); stop_code($cities); return $cities; }
/** * Renvoie l'id de la prochaine photo, * ou de la première si on est arrivés à la dernière photo * */ function get_next_pic($book_id, $pic_id) { $q = $this->db->select('id')->from('book_pics')->where('book_id', $book_id)->where('order', $pic_order + 1)->limit(1)->get(); //code($q->result()); if ($q->num_rows() == 1) { return $q->row()->id; } else { // on a atteint la dernière photo on retourne à la première $q = $this->db->from('book_pics')->where('book_id', $book_id)->where('order', 1)->limit(1)->get(); stop_code($q->result()); return $q->row()->id; } }