1

how do you handle middle sized projects with PHP and Zend Framework. Do you use Zend DB Table / Row for your Models and Database operations ? Or do you have some kind of Abstract Model class with your SQL Statements ?

I would like to hear some opinions, thanks.

4
  • 2
    I wouldn't use Zend. It is hard to use. You better off using Codeigniter Commented Nov 1, 2009 at 15:35
  • 3
    CodeIgniter is simpler but also poorer quality than ZF and with far less features. Perseverance will pay off! Commented Nov 2, 2009 at 0:50
  • Zend is extremely easy to use. It's only hard to LEARN :D Commented Nov 2, 2009 at 9:40
  • Is it interchangeable? I mean php is like c syntax, and very similar with js. But if you'r zending, can you switch back to another environment? Commented Feb 12, 2011 at 20:43

3 Answers 3

6

I'd recommend Zend_Db_Table and Row for basic handling of database stuff. It's not very advanced (see Doctrine for a full ORM) but is a good way to encapsulate functionality and you can add custom functionality to Row objects.

You can always add raw SQL methods to your models:

   class MyModel extends Zend_Db_Table_Abstract {

        public function getSomething(){
            return $this->getAdapter()->fetchAll("SELECT * FROM `tbl`");
        }

    }
Sign up to request clarification or add additional context in comments.

3 Comments

+1; this is basically what my answer said. In past projects where I used ZF, we derived classes from Zend_Db_Table_Abstract for each of our tables; it worked rather well, and allowed us to have a class hierarchy supporting common capabilities between some types of tables (lookup tables, for example).
@James: Do you extend only Zend_Db_Table Abstract or altough Zend_Db_Table_Row?
We only extended Zend_Db_Table_Abstract; we probably could have saved ourselves a bit of work by extending Zend_Db_Table_Row too, though. We ended up with two layers of models--the concrete table classes, and a second application layer model that utilized those table classes.
1

We personally use Zend_Db_Select() in models in our company. It's because we use many joins and stuff in our ecommerce software. For simple apps is Zend_Db_Table suitable.

Comments

1

I've been using Doctrine lately for the DB layer and haven't looked back. I found it simple to populate object graphs from the DB. Other solutions were too cumbersome in dealing with relationships for my liking.

My domain model sits above the DB layer and manages the business logic.

It really depends on your domain model though. The current version of Doctrine requires all models to extend a class, so it's not suitable if you need model inheritance. Also, it's only suitable if your model is similar to your DB structure.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.