Skip to content

Commit

Permalink
control
Browse files Browse the repository at this point in the history
  • Loading branch information
cws13003 committed Dec 4, 2017
1 parent add5c7a commit 149688a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 70 deletions.
54 changes: 14 additions & 40 deletions www/application/controllers/User_Tweets.php
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
}

}
43 changes: 13 additions & 30 deletions www/application/models/User_Tweets_Model.php
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();
}
}
?>

0 comments on commit 149688a

Please sign in to comment.