This is thoroughly confusing me. I am trying to gather very basic statistics on my site, namely how many hits I am getting per day.
In a superclass that every controller inherits I have this code.
// log every hit
if(STATISTICS == 'all')
{
$stat = new Statistic();
$stat->ip = $this->_get_ip_address();
$stat->save();
}
I am loading the spark before this block. I do have a table setup named Statistics. I have the Model file created named Statistic with a classname of Statistic. Everything works well except when I try to save.
I can print out the $stat object and it returns an Active Record Object with everything set up properly. But for some reason when I try to call $stat->save(); every page just returns an Internal Server Error.
I have not added a new Model to my site in a while so I may have forgotten something, but this is really bugging me.
Anyone have any ideas?
More Information:
My Statistic Model:
class Statistic extends ActiveRecord\Model {
}
It seems that nothing was wrong with my code at all. It all works beautifully.
Protip: Don’t forget to set your id to auto increment in the database.