Re: Fwd: DB_DataObject : doc uncomplete and questions
| From: | Trevan Devaun Richins | Date: | Tue, 22 Mar 2005 18:21:49 +0000 |
| Subject: | Re: Fwd: DB_DataObject : doc uncomplete and questions | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18234@lists.php.net to get a copy of this message | ||
I believe the setters/getters are not used to just access one row like
StaticGet does. They are only there to make DO more object-orientated.
Meaning, you can access the variables using functions instead of
direct access, (so the variables could be defined as private (if you are
using PHP 5)).
As for making the queries, you use factory in conjunction with find,
insert, or update. Such as:
$DO_object = DB_DataObject::factory('My_table');
$DO_object->setID("10");
$DO_object->setName("Bob");
$DO_object->find(1);
$address = $DO_object->getAddress();
$phone = $DO_object->getPhone();
$DO_object->setPhone("111-2222");
$DO_object->update();
Trevan
foxmask wrote:
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
i've just find that staticGet could cover my need about getters but what's about setters ? ---------- Forwarded message ---------- From: foxmask <foxmask@gmail.com> Date: Tue, 22 Mar 2005 17:13:36 +0100 Subject: DB_DataObject : doc uncomplete and questions To: pear-general@lists.php.net I searched what paramter i missed in my foxmask.ini file to be able to add setters/getters in each table.php class. For person who are interesting ; i've just read the Generator.php file provides by the DB_DataObject package ; and saw that we have to put in the .ini file : generate_getters = 1 generate_setters = 1 Now i want to know a last thing. Do we have to write ourselves the query to insert/update/delete in the database ? 1) if yes, it's a damage to have to do it as the createTable.php script is able to open the database ; connect to it and generate the var $row and setters/getters For example in My_Table.php Class My_Table { var $id; function getRow1 () { $db->query("select row1 from my_table where id = $this->id"); } } 2) if no ; what's the parameter i missed (and dont find in Generator.php) to be able to generate the queries ? kind regards. -- Founder Member of PhpFr.Org a PHP Portal for French Community http://phpfr.org-- Trevan Richins Computer Science Dep. System Admin
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc