2008年9月3日星期三

Re: [fw-db] The best way to approach the database

This isn't going to help but the best thing to do is what you feel is the
best thing! There is no right way I've learnt in any of this, as long as it
works!

Having said that I started using db_table, then realised I wrote more of my
own queries so just use db directly. db_table is very useful if you're not
doing joins (although they can be done). You will probably end up writing
your own model handlers to handle any data and allow you to work with it as
you want to.

For instance I have a model built on the back of a db class, each model
could then in turn be built on the back of an xml class etc etc. I use
fetchById() for instance which creates a db_select query. I pass the array
returned to a new model class which then allows me to get the data and store
common procedures. Again the data passed to my models could be anything in
an array. The same principals can be applied with db_table as well.

By far the best (in my opinion) tool in the box is db_select.


jjsanders wrote:
>
> Hello everyone.
>
> I'm confused. First I thought about writing my own class to talk to my
> (mysql) database. But then I thought, what Am I doing? Zend is actually
> doing this for me. So then i tried several things. And I ended up by just
> writing my full sql statement and then using $this->db->fetchAll($sql);
> But
> I have the feeling that this is not what Zend_Db was aiming for. I read
> in
> several places that the use of Zend_Db_Table is preferable.
> Can someone please help me out and thell me what the best thing is to do?
>
> Thanks in advance.
>
> J. Sanders
>
>


-----
Simon

http://www.ajb007.co.uk/
--
View this message in context: http://www.nabble.com/The-best-way-to-approach-the-database-tp19289843p19290910.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: