-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,15 @@ | ||
<?php | ||
defined('BASEPATH') OR exit('No direct script access allowed'); | ||
|
||
class User_Tweets extends CI_Controller { | ||
|
||
function __Construct(){ | ||
parent::__Construct (); | ||
<<<<<<< HEAD | ||
//$this->load->library('session'); | ||
======= | ||
>>>>>>> f4837a582f4adec40ee0abbdbcab7529d12c3238 | ||
$this->load->database(); // load database | ||
$this->load->model('User_Tweets_Model'); // load model | ||
$this->output->enable_profiler(TRUE); | ||
<?php defined('BASEPATH') OR exit('No direct script access allowed'); | ||
class User_Tweets extends CI_Controller { | ||
function __Construct(){ | ||
parent::__Construct (); | ||
|
||
$this->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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,15 @@ | ||
<?php | ||
class Users_Tweets_Model extends CI_Model { | ||
|
||
public function __construct() | ||
{ | ||
$this->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(); | ||
} | ||
} | ||
?> |