Re: Contributing / DB_Object

From: Date: Thu, 02 May 2002 07:53:42 +0000
Subject: Re: Contributing / DB_Object
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-5944@lists.php.net to get a copy of this message
(I hope I don't post twice but my smtp server seems to have problems) (tomas about db_oo) > Very nice class indeed. I could share some code to add AND/OR SQL > functionality. My fear with that classes is the support for JOIN/UNIONs, > do that class support them? (@see Alan mail for db_oo) DB_Object support them because when you do a 'SELECT' operation, it's you who write the SQL query. And it works fine if the result is not a mix of the two tables. Example : table user : id name email id_group table user_group : id name to make groups of users. Supposing that we have the corresponding classes : class user { var $id; var $name; var $email; var $id_group; (...) } class user_group { var $id; var $name; (...) } $db is a DB object. If you want to get all the user objects that belong to the group 'foo', you will write : $sql = "SELECT U.* FROM user AS U,user_group AS G WHERE U.id_group=G.id AND G.name='foo'"; the array of (real) user objects will be get with : $array = DB_Object::multipleLoad($db, "user", $sql, new user()); it's quite simple. Yet, if the result is a mix of several tables, you can't use DB_Object. > I recommend you to read the FAQ at > http://pear.php.net/faq.php. > :-o ! Sorry !!! I thought that it was a 'user' FAQ only !!! Thanks for your response. Fabien

« previous php.pear.dev (#5944) next »