[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-developers] Re: how does setup work
From: |
totschnig . michael |
Subject: |
[Phpgroupware-developers] Re: how does setup work |
Date: |
Tue, 24 Jun 2003 21:02:09 -0400 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Common Lisp, i386-redhat-linux) |
Michael Dean <address@hidden> a écrit:
> On Tue, 2003-06-24 at 11:51, address@hidden wrote:
>> but it only does NOT hit the database, if you use the oproc db object,
>> right? In sitemgr, I want to insert a new value into the database on a
>> specific upgrade, than retrieve the insert_id, and do some database
>> updates based on this value. I can not use the oproc db object, since
>> it does not have the get_last_insert_id function. Is there a solution
>> to this problem?
>
> No - it does not hit the database if you already have been upgraded to
> that version. Remember that the functions ALWAYS operate on the
> baseline structure, but only operate on the database if it contains a
> newer version than what you're currently at.
>
> Why can't you use the db object from the instance of the processor? It
> is the same class in the API. Don't confuse the oproc object with a
> database class. The query methods and such are just helper methods that
> forward the calls to the contained db object.
What I experienced was, when using something like
$db2 = $phpgw_setup->db;
$db2->query("INSERT ...")
$site_id = $db2->get_last_insert_id(...);
... other database updates
the insert and the updates where executed on each run of setup, but
when using
$phpgw_setup->oProc->query(""INSERT ...")
$site_id = $phpgw_setup->oProc->get_last_insert_id(...);
... other database updates
I got an error about function get_last_insert_id not defined.
Finally, I found a solution, that seems to work:
$phpgw_setup->oProc->query("INSERT INTO ...)");
//selecting the insert_id from the previous insert
$phpgw_setup->oProc->query("SELECT cat_id FROM ...");
if ($phpgw_setup->oProc->next_record())
{
$site_id = $phpgw_setup->oProc->f('cat_id');
... database updates
Michael