Hi. I just made a simple module through the command.
My database and tables are done. But when I go to my module in the modules menu, and then I click to create, this error appears: "Unknown column 'id' in 'field list". The module is named courses, my id column of my table courses is coursesID.
Why fuel is trying to get a field that is not in my database?
I put information in my table, now the main page of the module displays the information, however here appears a php error "Message: Undefined index: id". The problem must be related.
I tried to specify the fields with db->select() and it works in certain way, it only displays those fields, however it's still displaying the error.
How can I fix it?
Comments
function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'desc', $just_count = FALSE) { $this->db->select('coursesID as id, column1, column2, column3...etc'); $data = parent::list_items($limit, $offset, $col, $order, $just_count = FALSE); return $data; }
Also, did you set the $key_field property on your model to coursesID?
But where do I have to set the $key_field?
I did what you told me about the alias, and the main page of the module was not displaying errors. But when I clicked on create it's the same database error
Then I set public $key_field = array('coursesID'); above the model's construct function. Finally the create page is working. But now the main page display the same php error that I mentioned.
Also, I'd set the $key_field to just 'coursesID' not wrapped in an array unless you have a compound key