Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- */
- class News_model extends CI_Model
- {
- function __construct()
- {
- parent::__construct();
- }
- function get_all(){
- $data = array();
- $this->db->select('*');
- $Q = $this->db->get('news');
- // $sql = "SELECT * FROM news ORDER BY id_news DESC;";
- // $Q = $this->db->query($sql);
- if ($Q->num_rows()>0) {
- foreach ($Q->result_array() as $key => $row) {
- $data[]=$row;
- }
- }
- $Q->free_result();
- return $data;
- }
- function get_by_id($id){
- $data = array();
- $this->db->select('*');
- $this->db->where('id_news',$id);
- $Q = $this->db->get('news');
- if ($Q->num_rows()>0) {
- $data=$Q->row_array();
- }
- $Q->free_result();
- return $data;
- }
- function update($id,$input){
- $this->db->where('id_news',$id);
- $action = $this->db->update('news',$input);
- return $action;
- }
- function add($input){
- $action = $this->db->insert('news',$input);
- return $action;
- }
- function delete($id){
- $this->db->where('id_news',$id);
- $action = $this->db->delete('news');
- return $action;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment