Skip to content

Commit

Permalink
controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
cws13003 committed Dec 4, 2017
2 parents c796f73 + f4837a5 commit 9455a9d
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 3 deletions.
83 changes: 83 additions & 0 deletions db/lamp_2017-12-03.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ************************************************************
# Sequel Pro SQL dump
# Version 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.7.20)
# Database: lamp
# Generation Time: 2017-12-03 19:18:51 +0000
# ************************************************************


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


# Dump of table Tweets
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Tweets`;

CREATE TABLE `Tweets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`tweet` char(140) DEFAULT NULL,
`date_time` datetime DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

LOCK TABLES `Tweets` WRITE;
/*!40000 ALTER TABLE `Tweets` DISABLE KEYS */;

INSERT INTO `Tweets` (`id`, `tweet`, `date_time`, `user_id`)
VALUES
(1,'testing tweet! one two three','1000-01-01 00:00:00',1),
(2,'testing tweet again! four five six','1000-01-01 00:00:00',2);

/*!40000 ALTER TABLE `Tweets` ENABLE KEYS */;
UNLOCK TABLES;


# Dump of table Users
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Users`;

CREATE TABLE `Users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`first_name` text,
`last_name` text,
`username` char(20) DEFAULT '',
`password` text,
`email` text,
`url` text,
`location` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

LOCK TABLES `Users` WRITE;
/*!40000 ALTER TABLE `Users` DISABLE KEYS */;

INSERT INTO `Users` (`id`, `first_name`, `last_name`, `username`, `password`, `email`, `url`, `location`)
VALUES
(1,'shemona','singh','mona','pass','shemona.singh@uconn.edu',NULL,'milford'),
(2,'chris','stumper','chris','pass2','chris.stumper@uconn.edu',NULL,'simsbury');

/*!40000 ALTER TABLE `Users` ENABLE KEYS */;
UNLOCK TABLES;



/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
2 changes: 2 additions & 0 deletions www/application/controllers/All_Tweets.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function __Construct(){

public function index() {
$this->data['posts'] = $this->All_Tweets_Model->getPosts(); // calling Post model method getPosts()
$this->load->view('templates/header', NULL);
$this->load->view('home', $this->data); // load the view file , we are passing $data array to view file
$this->load->view('templates/footer', NULL);
}

}
9 changes: 8 additions & 1 deletion www/application/controllers/User_Tweets.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ class User_Tweets extends CI_Controller {

function __Construct(){
parent::__Construct ();
<<<<<<< HEAD
//$this->load->library('session');
=======
>>>>>>> f4837a582f4adec40ee0abbdbcab7529d12c3238
$this->load->database(); // load database
$this->load->model('Users_Tweets_Model'); // load model
$this->load->model('User_Tweets_Model'); // load model
$this->output->enable_profiler(TRUE);
}

public function index() {
<<<<<<< HEAD
// load form to tweet
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
Expand All @@ -28,6 +32,9 @@ public function index() {


$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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ 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");
Expand Down
2 changes: 1 addition & 1 deletion www/application/views/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<?php echo $post['first_name'];?>
<?php echo $post['last_name'];?>
<?php echo $post['username'];?>
</div>
</div>
<div class="col-md-8">
<?php echo $post['tweet'];?>
<?php echo $post['date_time'];?>
Expand Down
1 change: 1 addition & 0 deletions www/application/views/templates/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
<body>

<h1><?php echo $title; ?></h1>
<h2>Hello</h2>
1 change: 0 additions & 1 deletion www/application/views/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<div class="row">
<?php foreach($posts as $post){?>
<div class="col-md-4">
<?php echo $post['first_name'];?>
<?php echo $post['last_name'];?>
<?php echo $post['username'];?>
</div>
Expand Down
1 change: 1 addition & 0 deletions www/tmp/ci_session27ff9b439dbea0a593e5a60be5666916b5b2a907
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__ci_last_regenerate|i:1512329390;

0 comments on commit 9455a9d

Please sign in to comment.