Good idea. :-)
Below is the last few lines of the var_dump($inventory_item) output.
To my inexperienced eye, it appears that it has the value of an empty
string. Perhaps the real essence of the problem, is that it is being
assigned a string rather than an integer?
Below that, you can also see the debugoutput. Again, I have to ask
why the '?' in the 'PrepareQuery' is not being converted into either a
legitimate value, nor a NULL in the SQL query? (you said that it
should be converted into either one or the other, but it ends up being
converted into nothing at all, making for invalid SQL).
Thanks again for your ongoing dialogue on this issue. Even if I've
been doing things incorrectly, I do want to fully understand why.
Cheers,
Nik.
-----------------------------------------------
["pending"]=>
int(0)
["id"]=>
int(1105)
["notes"]=>
string(0) ""
["mandatory"]=>
int(0)
["shared"]=>
int(0)
["calculation"]=>
string(0) ""
["sort"]=>
int(1)
["description"]=>
string(0) ""
["grams"]=>
string(0) ""
["item"]=>
int(1)
["inventory"]=>
int(82)
}
FACTORY DEBUG:
1 Query: SELECT person.id, person.external_user_id, person.name FROM
person WHERE person.external_user_id=2
1 Query: SELECT inventory.id, inventory.name, inventory.description,
inventory.person FROM inventory WHERE id=82
1 Query: SELECT walk.id, walk.name, walk.date, walk.persons,
walk.days, walk.inventory FROM walk WHERE inventory=82
1 Query: SELECT inventory_item.id, inventory_item.notes,
inventory_item.mandatory, inventory_item.shared,
inventory_item.calculation, inventory_item.sort,
inventory_item.description, inventory_item.grams, inventory_item.item,
inventory_item.inventory FROM inventory_item WHERE inventory=82
1 PrepareQuery: UPDATE inventory_item SET notes=?, mandatory=?,
shared=?, calculation=?, sort=?, description=?, grams=?, item=?,
inventory=? WHERE id=?
1 Query: UPDATE inventory_item SET notes='', mandatory='N',
shared='N', calculation='', sort=1, description='', grams=, item=1,
inventory=82 WHERE id=1105
1 Query error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near ' item=1, inventory=82 WHERE id=1105' at line 1
-----------------------------------------------
On 20/09/2008, at 2:51 PM, Manuel Lemos wrote:
> Hello,
>
> on 09/20/2008 01:11 AM Nik Sands said the following:
> > But you said that a '?' in a PrepareQuery should be converted to
> > either an SQL NULL, or to a valid value in the actual Query.
> >
> > This is not happening in this case.
>
> If you look at the generated code you can see this for setting the
> prepared query parameter of the grams field.
>
> if(IsSet($this->grams))
> {
> MetabaseQuerySetInteger($this->database,$statement,7,$this->grams);
> }
> else
> MetabaseQuerySetNull($this->database,$statement,7,'integer');
>
> Maybe you think you are doing the things correctly, but you are not.
>
> Try using var_dump($inventory_item); before calling
> $inventory_item->save(); and show the results here so we can double
> check that the grams variable is really set to null or undefined.
>
> --
>
> 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]