1. Adapter
Agavi is really great FW, peace of art IMO – but I’ve been using Zend
Framework for a while before I found it (Agavi) and lack of Zend_Db
integration bothered me enough to make Me create that by myself.
http://pastie.caboo.se/170051
It is not sophisticated, but works. I think there is few features that I
can add later (more profiler options maybe?).
It’s an extension, so enabling it in application just needs some
adjustments in databases.xml e.g.:
<database name="zend" class="BaseZendDbDatabase">
<parameters>
<parameter name="adapter">Pdo_Sqlite</parameter>
<parameter name="config">
<parameters>
<parameter
name="dbname">/usr/www/mczp/app/data/mczp.sqlite</parameter>
</parameters>
</parameter>
<parameter name="use_profiler">true</parameter>
</parameters>
</database>
Of course don’t forget add /BaseZendDbDatabase/ class to autoloads e.g.
<autoload
name="BaseZendDbDatabase">%core.lib_dir%/database/BaseZendDbDatabase.class.php</autoload>
2. Models
But what about integration with Agavis models management?
It required few lines of code more:
http://pastie.caboo.se/170085
and autoload line e.g.
<autoload
name="BaseZendDbModel">%core.lib_dir%/model/BaseZendDbModel.class.php</autoload>
et voila, creating agavis models using Zend_Db_Table is as simple as:
<?php
class Blog_PostsModel
extends BaseZendDbModel
{
protected $_name = 'news';
protected $_primary = 'id';
}
?>
P.S. I know there is a problem of metadata (if cache is not provided,
Zend_Db_Table queries database for table details each request),but in my
case I would rather set that cache on my own, or even var_export that
data and hard code it in the class.
_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users