#467: DB_DataObject integration
--------------------------------------+-------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: david
Type: enhancement | Status: new
Priority: normal | Milestone: 1.0
Component: database | Version:
Severity: normal | Keywords:
--------------------------------------+-------------------------------------
I just attached two files
copy AgaviDbdataobjectDatabase.class.php and AgaviDbdataobject.class.php
anywhere you want. then add its parent directory to include path
(DataObjects will try to include AgaviDbdataobject.class.php) , then you
have to autoload AgaviDbdataobjectDatabase.class.php and
AgaviDbdataobject.class.php.
set database like the following example
{{{
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configurations>
<configuration>
<databases default="default">
<database name="default" class="AgaviDbdataobjectDatabase">
<parameters>
<parameter name="dsn">mysql://user:[EMAIL PROTECTED]/db</parameter>
<parameter name="dataobject">
<parameters>
<parameter name="debug">0</parameter>
<parameter name="class_location"></parameter>
<parameter name="require_prefix"></parameter>
<parameter name="class_prefix"></parameter>
<parameter name="quote_identifiers">true</parameter>
<parameter name="db_driver">MDB2</parameter>
<parameter name="proxy">full</parameter>
</parameters>
</parameter>
</parameters>
</database>
</databases>
</configuration>
</configurations>
}}}
generate your DataObjects and put those in models directory of module.
you can use the following ini file to generate DataObjects
{{{
[DB_DataObject]
database = mysql://user:[EMAIL PROTECTED]/db
schema_location = ./
class_location = ./
class_prefix =
extends_location = AgaviDbdataobject.class.php
extends = AgaviDbdataobject
generator_class_rewrite = 0
build_views = 0
generator_include_regex = /^.*/i
generator_exclude_regex = /^.*_seq/i
generate_setters = 0
generate_getters = 1
generator_add_validate_stubs = 1
}}}
autoload your DataObjects in config directory of module then you can use
your DataObjects like the following example :)
{{{
$entries = $this->getContext()->getModel('Blog_entries');
$entries->date = time();
$entries->title = "First entry";
$entries->body = "Body";
$entries->insert();
}}}
I don't know if I've done every thing in the right way.
--Armen
--
Ticket URL: <http://trac.agavi.org/ticket/467>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5
_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets