How can I use Zend_Db without SQL queries?

The last time I worked with Zend_Db, I recall what I used to manually write SQL queries. I was looking for some sort of ORM application, but since I was reading something like Zend_Db I can do that too, I started trying it, but I can’t find a good tutorial, explanation, or good documentation.

I've read something figurative about the gateway and the ModelMapper class, but I can't figure it out.

Can someone shine my way ?: P

+2


a source to share


1 answer


Everything you need to get started is available in the Zend Framework Reference Manual forZend_Db

.

Zend_Db_Table

is the TableData Gateway . It has very limited ORM capabilities. This is mainly due to the ability to define relationships between tables. Dependent rows can be lazy loaded using appropriate lookup methods on the Zend_Db_Row

instances
returned by the query in TDG. It won't necessarily force you to write SQL, but less SQL. Under the hood Zend_Db_Table

, a subclass is used Zend_Db_Select

to create SQL queries via the Fluent API . See the Reference Guide on how to work with TDG and how to get associated data.

The ModelMapper you are linking to is another template called DataMapper . Typically, this is used when working with the Domain Model . The DataMapper handles impedance mismatch that typically occurs when domain objects and their persistent representation do not match. There is no usual recipe for this class. Depending on the number of inconsistencies, the DataMapper can get quite complex. Efforts to create a generic mapper for ZF have been abandoned in favor of integrating Doctrine with ZF . But an example of a custom DataMapper can be found in the reference manual.



You can look around SO for PHP ORM , especially this question:

+3


a source







All Articles