NextID and DB_DataObjects
| From: | LIMBOURG Arnaud | Date: | Tue, 19 Nov 2002 13:56:46 +0000 |
| Subject: | NextID and DB_DataObjects | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-2757@lists.php.net to get a copy of this message | ||
Hello,
I started using DataObject and have a question regarding the use of it and
PEAR::DB::nextID mechanism.
I need to generate an idea, part of which comes from a sequence. I assume
that i have things available in the extended class, so is the following code
the right way to do it ?
function newID($userid)
{
$this->_connect();
$connections =
&PEAR::getStaticProperty('DB_DataObject','connections');
$__DB= &$connections[$this->_database_dsn_md5];
$prefix = date('Y-m-d');
$increment = $__DB->nextId()('projet');
return $prefix . '-' . $userid . '-' . $increment;
} // end func newID
I did a copy/paste from DataObjects::insert method but i'm not sure if i do
it properly.
Arnaud.