Welcome Guest, Not a member yet? Register   Sign In
$query = $this->db->get('news');
#1

I am working my way through the display News section of the tutorials.

My News_model.php is just cut and past from the tutorial:


PHP Code:
<?php
class News_model extends CI_Model {

        public function __construct()
        {
                $this->load->database();
        }
        
public function get_news($slug FALSE)
{
       if ($slug === FALSE)
       {
               $query $this->db->get('news');
               return $query->result_array();
       }

       $query $this->db->get_where('news', array('slug' => $slug));
       return $query->row_array();
       


But when viewing the news page I get this error:

A Database Error Occurred
Error Number: 1146
Table 'kvpuctvh_igni857.adnews' doesn't exist
SELECT * FROM `adnews`
Filename: models/News_model.php
Line Number: 13

It is trying to select from table adnews but the model clearly shows it is trying to query the news table in the db.  So why is it adding "ad" to the front of the table name?

Confused.
Reply


Messages In This Thread
$query = $this->db->get('news'); - by Ragwin - 09-17-2016, 10:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB