Could someone who understands DBUtil better than I please look at the Manipulating Tables Wiki page, and update the examples so they all reference the same tables/fields created in the FIRST example ?
I would happily do it -- but if I could do it, I evidently wouldn't NEED it. :-)
Thanks.
========================================================== Chris Candreva -- ch...@westnet.com -- (914) 948-3162 WestNet Internet Services of Westchester http://www.westnet.com/
On Thu, 2 Sep 2010, Mateo TibaPalacios wrote: > Wowquite old code was there eh?
> I've updated that wiki page and the next one, for Standard Fields. > Greetings
Thank you !
Another question, on the updateObject documentation. It says the return value is "The result set from the update operation" . What exactly does that mean in this context ?
And, specificly, what should I expect to seee returned if the update operation didn't find anything to update (so that I know I need to do an insert instead) ?
What's especially confusing is that while these are called "Objects" it seems they are really just hashes, as there is no 'new' done to create them, nor are theire methods to call on them.
========================================================== Chris Candreva -- ch...@westnet.com -- (914) 948-3162 WestNet Internet Services of Westchester http://www.westnet.com/
Indeed no classes handled on 1.2.x and previous, just arrays as "Objects".
Well, specifically I don't know what to expect on a failed update, may be false, but it's supposed that if you have the object.id, the item already exists, I mean, you know what you're doing.
I guess you may test var_dump of the results. If I remember ok, updateObject and insertObject returns the whole object (record array) on success, or (bool) false on failure.
>> I've updated that wiki page and the next one, for Standard Fields. >> Greetings
> Thank you !
> Another question, on the updateObject documentation. It says the return > value is "The result set from the update operation" . What exactly does > that mean in this context ?
That is not quite correct.
insertObject() and updateObject() return the object as it is after the update (in the case of insert, the "id" (autoincrement) if it exists is added) ... if an error occurs, false is returned.
> And, specificly, what should I expect to seee returned if the update > operation didn't find anything to update (so that I know I need to do an > insert instead) ?
That shouldn't happen. If you pass an object, presumably it has an autoincrement ID field so the object knows which row to update. If you don't have such a field, you need to pass a $where clause to the update routine. If this where clause fails to match a table row, you still get back the object because from an SQL point of view, you didn't cause an error.
It is up to the calling code to ensure that the correct parameters were passed to updateObject(). So if you want to update an object, you should first try to select it to ensure that it exists (presumably in your pnuser/pnadmin code). If you manage to retrieve an object, you can pass the object (if it has an ID field) or the same where clause to updateObject().
> What's especially confusing is that while these are called "Objects" it > seems they are really just hashes, as there is no 'new' done to create them, > nor are theire methods to call on them.
Correct. For DBUtil and object is a data array ... this is for historical reasons; when I first wrote DBUtil, PHP-4 object model was really quite basic + PostNuke did not know anything about objects (there was no PNObject yet).
On Fri, 3 Sep 2010, RNG wrote: > That shouldn't happen. If you pass an object, presumably it has an > autoincrement ID field so the object knows which row to update. If you > don't have such a field, you need to pass a $where clause to the > update routine. If this where clause fails to match a table row, you > still get back the object because from an SQL point of view, you > didn't cause an error.
I see. In my particular application it is a form that can only be filled out once per logged in user (reflecting a directory entry), so I'm useing the logged in uid as the record id to keep things simple.
Usually with updates you get back a count of the number of records updated, and if it's 0 I know to do an insert.
========================================================== Chris Candreva -- ch...@westnet.com -- (914) 948-3162 WestNet Internet Services of Westchester http://www.westnet.com/
<ch...@westnet.com> wrote: > On Fri, 3 Sep 2010, RNG wrote:
>> That shouldn't happen. If you pass an object, presumably it has an >> autoincrement ID field so the object knows which row to update. If you >> don't have such a field, you need to pass a $where clause to the >> update routine. If this where clause fails to match a table row, you >> still get back the object because from an SQL point of view, you >> didn't cause an error.
> I see. In my particular application it is a form that can only be filled > out once per logged in user (reflecting a directory entry), so I'm useing > the logged in uid as the record id to keep things simple.
> Usually with updates you get back a count of the number of records updated, > and if it's 0 I know to do an insert.
> ========================================================== > Chris Candreva -- ch...@westnet.com -- (914) 948-3162 > WestNet Internet Services of Westchester > http://www.westnet.com/
> -- > You received this message because you are subscribed to the Google Groups "Zikula" group. > To post to this group, send an email to zikula-discussions@googlegroups.com. > To unsubscribe from this group, send email to zikula-discussions+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/zikula-discussions?hl=en-GB.
On Fri, 3 Sep 2010, RNG wrote: > So first do a select for "where uid=$uid" ... if you get back a result > you need an update, otherwise it's an insert.
Or -- in the pnForm constructor when I see if the form can be pre-populated, do an insert then of a blank object if it doesn't already exist.
Thanks !
========================================================== Chris Candreva -- ch...@westnet.com -- (914) 948-3162 WestNet Internet Services of Westchester http://www.westnet.com/
<ch...@westnet.com> wrote: > On Fri, 3 Sep 2010, RNG wrote:
>> So first do a select for "where uid=$uid" ... if you get back a result >> you need an update, otherwise it's an insert.
> Or -- in the pnForm constructor when I see if the form can be pre-populated, > do an insert then of a blank object if it doesn't already exist.
> Thanks !
> ========================================================== > Chris Candreva -- ch...@westnet.com -- (914) 948-3162 > WestNet Internet Services of Westchester > http://www.westnet.com/
> -- > You received this message because you are subscribed to the Google Groups "Zikula" group. > To post to this group, send an email to zikula-discussions@googlegroups.com. > To unsubscribe from this group, send email to zikula-discussions+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/zikula-discussions?hl=en-GB.