From 62115f08136ecffde06a268084b85cead57865e7 Mon Sep 17 00:00:00 2001 From: Shemona Singh Date: Wed, 29 Nov 2017 19:17:56 -0500 Subject: [PATCH 1/2] playing with database --- www/application/controllers/All_Tweets.php | 18 ++++++++++++ www/application/models/All_Tweets_Model.php | 13 +++++++++ www/application/views/pages/home.php | 32 ++++++++++++++++++++- www/application/views/templates/header.php | 1 + 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 www/application/controllers/All_Tweets.php create mode 100644 www/application/models/All_Tweets_Model.php diff --git a/www/application/controllers/All_Tweets.php b/www/application/controllers/All_Tweets.php new file mode 100644 index 0000000..bd5eb5d --- /dev/null +++ b/www/application/controllers/All_Tweets.php @@ -0,0 +1,18 @@ +load->database(); // load database + $this->load->model('All_Tweets_Model'); // load model + $this->output->enable_profiler(TRUE); + } + + public function index() { + $this->data['posts'] = $this->All_Tweets_Model->getPosts(); // calling Post model method getPosts() + $this->load->view('posts_view', $this->data); // load the view file , we are passing $data array to view file + } + +} diff --git a/www/application/models/All_Tweets_Model.php b/www/application/models/All_Tweets_Model.php new file mode 100644 index 0000000..dcd70e3 --- /dev/null +++ b/www/application/models/All_Tweets_Model.php @@ -0,0 +1,13 @@ +db->select("first_name,last_name,username"); + $this->db->from('Users'); + $query = $this->db->get(); + var_dump($query->result_array()); + // return $query->result(); + } + +} +?> diff --git a/www/application/views/pages/home.php b/www/application/views/pages/home.php index 05824dd..42f548f 100644 --- a/www/application/views/pages/home.php +++ b/www/application/views/pages/home.php @@ -1 +1,31 @@ - + + + + + All Tweets + + + + +

Output Data

+ + + + + + + + + + + +
Post IdPost Title
first_name;?>last_name;?>
+ + + + + diff --git a/www/application/views/templates/header.php b/www/application/views/templates/header.php index f55cc2f..3522656 100644 --- a/www/application/views/templates/header.php +++ b/www/application/views/templates/header.php @@ -1,6 +1,7 @@ Twitter + load->helper('url'); ?> " /> From 9ee081bceef8df5489ac58f9698131ce2b38ae18 Mon Sep 17 00:00:00 2001 From: Shemona Singh Date: Wed, 29 Nov 2017 20:17:41 -0500 Subject: [PATCH 2/2] database changes --- www/application/controllers/All_Tweets.php | 2 +- www/application/models/All_Tweets_Model.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/application/controllers/All_Tweets.php b/www/application/controllers/All_Tweets.php index bd5eb5d..d5bcca1 100644 --- a/www/application/controllers/All_Tweets.php +++ b/www/application/controllers/All_Tweets.php @@ -12,7 +12,7 @@ function __Construct(){ public function index() { $this->data['posts'] = $this->All_Tweets_Model->getPosts(); // calling Post model method getPosts() - $this->load->view('posts_view', $this->data); // load the view file , we are passing $data array to view file + $this->load->view('home', $this->data); // load the view file , we are passing $data array to view file } } diff --git a/www/application/models/All_Tweets_Model.php b/www/application/models/All_Tweets_Model.php index dcd70e3..739b05e 100644 --- a/www/application/models/All_Tweets_Model.php +++ b/www/application/models/All_Tweets_Model.php @@ -1,5 +1,5 @@ db->select("first_name,last_name,username");