March 20, 2012

Framework for database manipulation

Question by Priyank Bolia

Is there a PHP framework, that lets me write such code.

class Item
{
    private $_id; //primary key
    private $name;
    private $price;
    function __construct($name, $price) {
       $this->name = $name;
       $this->price = $price;
    }
}
...
$item = new Item(...);
db->Save($item);
...
db->Delete($item);
...
db->Update($item);
...
Item[] = db->Fetch($whereClause);

Yes Admins, I searched on Google, but I got lost in the vast sea (Doctrine, Propel, ActiveRecords,…), asked a different question on SO (which prohibited me from comparison), so I am asking differently now, which framework lets me write such simple code, without much additional coding, no XML, YAML.
Or additionally how to write such if not there. Any pointers will be helpful. Off course I have PHP 5.3 and can use PDO, but performance is a concern (magic functions…), not extensive features list (we support this thing also, that you will never use).

OOPS: forgot to add, don’t want a framework like CakePHP, etc. I am writing simple php without frameworks, want just some libraries that I can include into my project and call the above syntax. Its ok for me, if it requires a little SQL behind.

Answer by Starx

There are many frameworks. See this for an example.

Every frameworks have there own way of API, through which you can use many features, such as db, xml.

  1. For ORM only Doctrine is very Excellent
  2. For rapid development and scaffolding features Codeigniter is very good.
  3. For in-depth framework with many pre-built libraries Zend-Framework is one of the best. It has libraries for Doctrine too.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!