Jay B Tue Feb 15 17:00:21 -0500 2011

Subject: MVC - model separated logic?

Hi Kien,

I would like to get all my database logic separated from my Controllers and Views, as it should in a proper MVC pattern.
How can I accomplish this with php.activerecord?

I've tried to make a nested model like this, but I keep getting errors when I need to access the static functions and variables (finders, updaters and so on).

class myModel {
function read( $id ) {
$existingSession = Session_model::find_by_id( $id ); // Throws error: Fatal error: Class 'Session_model' not found even though the file is included and works when running $new Session_model;
if (!is_null($existingSession))
return $existingSession->session_data;

Running the stable 1.0 version on PHP 5.3

Jono B Sun Feb 20 12:29:15 -0500 2011

Something like:

class myModel extends ActiveRecord\Model

    static $table_name = 'blog';

    public static function get_single_post($id)
        return self::find_by_id($id);