-
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
8 changed files
with
74 additions
and
67 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
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
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
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,15 +1,21 @@ | ||
<?php defined('BASEPATH') OR exit('No direct script access allowed'); | ||
class User_Tweets extends CI_Controller { | ||
function __Construct(){ | ||
parent::__Construct (); | ||
<?php | ||
defined('BASEPATH') OR exit('No direct script access allowed'); | ||
|
||
$this->load->database(); | ||
$this->load->model('User_Tweets_Model'); | ||
$this->output->enable_profiler(TRUE); | ||
} | ||
class User_Tweets extends CI_Controller { | ||
|
||
public function index(){ | ||
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); | ||
$this->load->view('user', $this->data); | ||
} | ||
function __Construct(){ | ||
parent::__Construct(); | ||
//$this->load->library('session'); | ||
$this->load->database(); // load database | ||
$this->load->model('User_Tweets_Model'); // load model | ||
$this->output->enable_profiler(TRUE); | ||
} | ||
|
||
public function index() { | ||
$this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts() | ||
$this->load->view('templates/header', NULL); | ||
$this->load->view('user', $this->data); // load the view file , we are passing $data array to view file | ||
$this->load->view('templates/footer', NULL); | ||
} | ||
|
||
} |
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,19 +1,36 @@ | ||
<?php | ||
class User_Tweets_Model extends CI_Model { | ||
function getPosts(){ | ||
//$_SESSION['user_id'] = $id; | ||
$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 getPosts(){ | ||
function addTweet(){ | ||
$this->load->helper('url'); | ||
|
||
//$this->load->library('session'); | ||
//session_start(); | ||
$user_id = 1; //$this->session->userdata('session_id'); | ||
$slug = url_title($this->input->post('title'), 'dash', TRUE); | ||
|
||
$this->db->select("first_name, last_name, username, tweet, date_time, location"); | ||
$this->db->from("Users, Tweets"); | ||
$this->db->where("Users.id = Tweets.user_id and Users.id = $user_id"); | ||
$this->db->order_by('date_time', 'DESC'); | ||
$query = $this->db->get(); | ||
return $query->result_array(); | ||
} | ||
$data = array( | ||
'tweet' => $this->input->post('tweet'), | ||
'date_time' => 10, | ||
'user_id' => 1 | ||
); | ||
|
||
return $this->db->insert('Tweets', $data); | ||
|
||
/* | ||
$this->load->helper('url'); | ||
$data = array( | ||
'tweet' => $this->input->post('tweet') | ||
); | ||
return $this->db->insert('tweets', $data); | ||
*/ | ||
} | ||
|
||
} |
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,3 +1 @@ | ||
<h3>Your form was successfully submitted!</h3> | ||
|
||
<p><?php echo anchor('form', 'Try it again!'); ?></p> |
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
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