Sorry, my last email was probably not very clear. Let me try
again... :-)
The code immediately below fails to save (and gives the debug output
shown below), but if I uncomment the two "Work around" lines, it saves
successfully. Why is this?
The debug output is the same as posted earlier in this topic.
Cheers,
Nik.
$grams = $form->GetInputValue("item_".$id."_grams");
if ( IsSet($grams) )
$inventory_item->grams = $grams;
else
$inventory_item->grams = null;
// Work around metastorage invalid SQL issue
//if ( ! $inventory_item->grams )
// $inventory_item->grams = null;
if ( ! $inventory_item->save() )
exit_error("Failed to save data for inventory item '".
$inventory_item->id."'");
On 19/09/2008, at 2:35 PM, Manuel Lemos wrote:
> Hello,
>
> on 09/19/2008 01:33 AM Nik Sands said the following:
> > it is optional:
> >
> > ...
> > <variable>
> > <name>grams</name>
> > <type>integer</type>
> > <optional>1</optional>
> > </variable>
> > ...
> >
> > It is being assigned immediately before the save() as follows:
> >
> > $inventory_item->grams = $form->GetInputValue("item_".$id."_grams");
> >
> > In this case, it is being assigned an empty value.
>
> That is the problem. If it is empty, don't assign it or set it to
> null .
>
> --
>
> Regards,
> Manuel Lemos
>
> Find and post PHP jobs
> http://www.phpclasses.org/jobs/
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>
>
========================================================
NIXANZ - http://nixanz.com/
Like to help out as a beta tester? Let me know which application
you'd like to test.
[Non-text portions of this message have been removed]