Re: [metal-dev] Metastorage 'persist' function producing invalid SQL
Hello,
on 09/19/2008 07:24 PM Nik Sands said the following:
> Hi Manuel,
>
> Thanks for looking at this for me. The class definition is attached
> to this email.
>
> The '?' is not getting replaced by a value, or by NULL, which is the
> problem.
It seems not file was attached to the message. Can you paste the class
definition so I can try to reproduce your problem?
I'm new to Metastorage, so forgive me if I've overlooked something obvious. Anyhow, I can't get my persist function to work reliably. I've using the same...
Hello, ... If the variable can be set to NULL, it means it is optional. Are you defining it as <optional>1</optional> ? The generated class should fail the...
it is optional: ... <variable> <name>grams</name> <type>integer</type> <optional>1</optional> </variable> ... It is being assigned immediately before the...
I thought metastorage was supposed to set it to NULL when generating the SQL automatically? The debug output shows it as being a '?' in the prepared query, but...
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),...
Hello, ... I think there is some confusion. An empty string is one thing. An undefined value is another thing. ... The above should be: if(strlen($grams)) ... ...
Hi Manuel, Thanks for your help... Is metastorage NOT supposed to replace this with a NULL in the SQL in this case? Is metastorage SUPPOSED to produce invalid...
Hello, ... I am not sure what you mean. The code generate by Metastorage sets the field to NULL if you set the respective optional variable to null or just not...
but in the situation I showed in my last example, it produces invalid SQL. Shouldn't this be avoided, no matter what the value of the variable? Metastorage...
Hello, ... ? in the prepared query is just a place holder that will be placed by the real value when the query is executed. If the variable is set to a value,...
Hi Manuel, Thanks for looking at this for me. The class definition is attached to this email. The '?' is not getting replaced by a value, or by NULL, which is...
Hello, ... It seems not file was attached to the message. Can you paste the class definition so I can try to reproduce your problem? -- Regards, Manuel Lemos ...
Hello, ... I generated the code of the class and it is correct. If you set the grams variable to null or unset it, it will be set a NULL on the database...
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...
Hello, ... 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)) { ...
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 ...
Hello ... As you may see the grams variable is set to an empty string "" and not null as it should be. Now you need to check your code to figure why it is not...
I already know why it is being set to an empty string: That is simply what has been stored by the formsgeneration class that I'm using. I would have expected...