Robert1995 Posted May 13, 2011 Report Posted May 13, 2011 (edited) Mi-am facut niste modele in code igniter pentru SQL , cine stie poate va trebuie si voua <?phpclass SubPage extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } public function getAll(){ $sql="SELECT * FROM sub_page where hidden = 0 order by creation_date desc"; $r = $this->db->query($sql); return $r->result_array(); } public function getById($id){ $this->db->from('sub_page'); $this->db->where('id', $id); $r = $this->db->get(); return $r->result_array(); } public function getAllByPageId($page_id){ $this->db->from('sub_page'); $this->db->where('page_id', $page_id); $this->db->where('hidden', 0); $r = $this->db->get(); return $r->result_array(); } public function getLastTen() { $sql="SELECT * FROM sub_page where hidden = 0 order by creation_date desc limit 10"; $r = $this->db->query($sql); return $r->result_array(); } public function enableById($id){ $data = array( 'hidden' => 0 ); $this->db->where('id', $id); $this->db->update('sub_page', $data); } public function disableById($id){ $data = array( 'hidden' => 1 ); $this->db->where('id', $id); $this->db->update('sub_page', $data); }}Astept comentarii P.S Mi-au trebuit 30 minute sa-mi dau seama de un lucru banal ce am uitat sa il fac , cine stie poate si voi aveti problema asta si va pot va ajuta in 'autoload' adaugati '$autoload['libraries'] = array('database');' Edited May 13, 2011 by Robert1995 greseli gramaticale Quote
tdxev Posted May 13, 2011 Report Posted May 13, 2011 incarca database in constructor..pune l in auto load doar daca folosesti database in toate controalele Quote
Robert1995 Posted May 13, 2011 Author Report Posted May 13, 2011 @tdxev din 10 tabele , implicit si modele cam 8 folosesc peste tot asa ca nu ma stresez pentru 2 tabele cu load in constructor , dar mersi de idee Quote