From 149688ad08d57cafe34ebf50ced8a3383f224009 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 3 Dec 2017 20:36:01 -0500 Subject: [PATCH] control --- www/application/controllers/User_Tweets.php | 54 +++++--------------- www/application/models/User_Tweets_Model.php | 43 +++++----------- 2 files changed, 27 insertions(+), 70 deletions(-) diff --git a/www/application/controllers/User_Tweets.php b/www/application/controllers/User_Tweets.php index 870d5f8..ea30205 100644 --- a/www/application/controllers/User_Tweets.php +++ b/www/application/controllers/User_Tweets.php @@ -1,41 +1,15 @@ -load->library('session'); -======= ->>>>>>> f4837a582f4adec40ee0abbdbcab7529d12c3238 - $this->load->database(); // load database - $this->load->model('User_Tweets_Model'); // load model - $this->output->enable_profiler(TRUE); +load->database(); + $this->load->model('User_Tweets_Model'); + $this->output->enable_profiler(TRUE); + } + + public function index(){ + $this->data['posts'] = $this->Users_Tweets_Model2->getPosts(); + $this->load->view('user', $this->data); + } } - - public function index() { -<<<<<<< HEAD - // load form to tweet - $this->load->helper(array('form', 'url')); - $this->load->library('form_validation'); - - $this->form_validation->set_rules('tweet', 'Tweet', 'required'); - - if ($this->form_validation->run() == FALSE) - $this->load->view('user_tweets'); - echo "false"; - else { - $this->Users_Tweets_Model->addTweet(); - $this->load->view('formsuccess'); - } - - - $this->data['posts'] = $this->Users_Tweets_Model->getPosts(); // calling Post model method getPosts() -======= - $this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts() ->>>>>>> f4837a582f4adec40ee0abbdbcab7529d12c3238 - $this->load->view('user', $this->data); // load the view file , we are passing $data array to view file - } - -} diff --git a/www/application/models/User_Tweets_Model.php b/www/application/models/User_Tweets_Model.php index f7211f3..c84a6c6 100644 --- a/www/application/models/User_Tweets_Model.php +++ b/www/application/models/User_Tweets_Model.php @@ -1,32 +1,15 @@ load->database(); - } - function getPosts(){ -<<<<<<< HEAD:www/application/models/Users_Tweets_Model.php - - //$_SESSION['user_id'] = $id; -======= ->>>>>>> f4837a582f4adec40ee0abbdbcab7529d12c3238:www/application/models/User_Tweets_Model.php - - - $this->db->select("first_name, last_name, username, tweet, date_time"); - $this->db->from('Users, Tweets'); - $this->db->where('Users.id = Tweets.user_id'); - $this->db->order_by('date_time', 'DESC'); - $query = $this->db->get(); - return $query->result_array(); - } - - function addTweet(){ - $this->load->helper('url'); - $data = array( - 'tweet' => $this->input->post('tweet') - ); - } - +class User_Tweets_Model extends CI_Model { + public function __construct(){ + $this->load->database(); + } + + function getPosts(){ + $this->db->select("first_name, last_name, username, tweet, date_time"); + $this->db->from('Users, Tweets'); + $this->db->where('Users.id = Tweets.user_id'); + $this->db->order_by('date_time', 'DESC'); + $query = $this->db->get(); + return $query->result_array(); + } } -?>