I really like what you have all done with this project. I have written a couple simplistic PHP AR solutions but all before late static bindings, so they had some arguably hacky workarounds.
I played around with this a bit and wrote a Zend application resource to basically integrate it:
class Dig_Application_Resource_Activerecord extends Zend_Application_Resource_ResourceAbstract
{
public function init ()
{
$options = $this->getOptions();
include_once($options['path']);
$cfg = ActiveRecord\Config::instance();
$cfg->set_model_directory(APPLICATION_PATH.'/models');
// we are going to let zf handle the app environment rather than handing this off to ar
$cfg->set_connections(array(APPLICATION_ENV => $this->connection($options['params'])));
$cfg->set_default_connection(APPLICATION_ENV);
}
public function connection($params) {
return 'mysql://' . $params['username'] .
':' . $params['password'] .
'@' . $params['host'] .
'/' . $params['dbname'];
}
}
You can then add activerecord support to your app with this in the application config file:
Subject: zend framework integration
I really like what you have all done with this project. I have written a couple simplistic PHP AR solutions but all before late static bindings, so they had some arguably hacky workarounds.
I played around with this a bit and wrote a Zend application resource to basically integrate it:
You can then add activerecord support to your app with this in the application config file: