I have a db with “events” from a event table that selects a eventid, year,month,day from my database in order to create dynamic links in a calendar.
Here is my controller:
$this->load->model('Sitemodel');
$month=date('n');
$year=date('Y');
$datearray=$this->Sitemodel->get_dates($month,$year);
$baseurl=base_url('site/event').'/';
foreach ($datearray as $datee) {
$dateeday=$datee['dtDay'];
$datacalendar[$dateeday]= $baseurl.$datee['eventid'];
}
$data['calenderinfo']=$this->calendar->generate($year,$month,$datacalendar);
$data['events']=$this->Sitemodel->get_10_all_events();
$this->load->view('index',$data);
here is my model:
function get_dates($month,$year){
$sql="SELECT eventid, DAY(dateof) AS dtDay, MONTH(dateof) AS dtMonth, YEAR(dateof) AS dtYear FROM event WHERE MONTH(dateof)=? AND YEAR(dateof)=?";
$result=$this->db->query($sql,array($month,$year));
return $result->result_array();
}
the error im getting is :
A Database Error Occurred
Error Number: 1054
Unknown column 'date' in 'order clause'
SELECT * FROM (`event`) ORDER BY `date` desc LIMIT 10
Filename: C:\wamp\www\event\system\database\DB_driver.php
Line Number: 330
I am unable to debug the error since it links back to the DB_driver when I know it must be something within my controller/model.
my DB structure for event table (names of columns) is:
eventid,eventtype,description,dateof(which is a date type)
I normally could figure this out if the error line of my controller/model/view is shown but instead it shows a error at the system level which totally throws me off. any help is greatly appreciated. Thank you.
The query that is producing the error, is happening somewhere other than the code you posted. It might be generated from a model call based on your schema file. Check your schema file and see if it has a
datereference instead ofdateof.This is one of the dis-advantages of an ORM, you can edit the schema all day, but if you don’t update the schema config file, and rebuild the model, all sorts of things can break.