model_main.php 502 B

123456789101112131415161718
  1. <?php
  2. class Model_main extends Model
  3. {
  4. public function get_posts(){
  5. $q = "SELECT * FROM `posts` ORDER BY `updated_at` DESC";
  6. return $this->db->query($q);
  7. }
  8. public function create_post($caption, $post){
  9. $q = "INSERT INTO `posts` SET `caption` = " . $this->db->escape($caption) .
  10. ", `post` = " . $this->db->escape($post) .
  11. ", `user_id` = " . $this->db->escape($_SESSION['user']['id']);
  12. $this->db->query($q);
  13. }
  14. }