sql error on newly created module when trying to access this module in the admin panel

I'm working on a module that will show recent projects. Each recent project can have multiple images associated with it. My first issue is that when trying to access this module in the admin panel, I get a sql error. I can see that it has the table in the where clause twice. Why is it producing a sql with the same table in the from clause twice?


sql output by the error message
SELECT recent_project.project_id, recent_project.details, recent_project_images.image, recent_project.slug, recent_project.published FROM (recent_project, recent_project) JOIN recent_project_images ON recent_project_images.project_id = recent_project.project_id ORDER BY project_id asc

my model
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class RecentProjects_model extends Base_module_model { //public $required = array('title'); function __construct() { parent::__construct('recent_project'); } // method used to list the data in the admin panel function list_items($limit = NULL, $offset = NULL, $col = 'project_id', $order = 'asc') { // the data to list $this->db->select('recent_project.project_id, recent_project.details, recent_project_images.image, recent_project.slug, recent_project.published', FALSE); $this->db->from('recent_project'); $this->db->join('recent_project_images', 'recent_project_images.project_id = recent_project.project_id'); $data = parent::list_items($limit, $offset, $col, $order); return $data; }

Comments

  • edited 12:34PM
    You can remove the $this->db->from('recent_projects'); because the parent model includes it in the $query = $this->db->get($this->table_name); around line 236.
  • edited November 2011
    That helped. Now I get to see recent projects module page, but it has this error twice on there:

    A PHP Error was encountered
    Severity: Notice

    Message: Undefined index: id

    Filename: controllers/module.php(293) : runtime-created function

    Line Number: 19
  • edited 12:34PM
    I had to add my other table's id column to get that error to go away. I'll be asking another similar question shortly.
  • edited 12:34PM
    Yes, the ID column is required for the list_items method.
Sign In or Register to comment.