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
#2

Check your database settings in application\config\database.php
One of the elements in de $db['default'] array is 'dbprefix'. Does this have the value 'ad' ?
Reply
#3

(09-17-2016, 11:52 PM)Wouter60 Wrote: Check your database settings in application\config\database.php
One of the elements in de $db['default'] array is 'dbprefix'. Does this have the value 'ad' ?

Yes! When I first installed Igniter the db config had ad as the dbprefix.  Simples.  Thx.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB