Search the web
Sign In
New User? Sign Up
metal-dev · MetaL Development
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Metastorage 'persist' function producing invalid SQL   Message List  
Reply | Forward Message #545 of 553 |
Re: [metal-dev] Metastorage 'persist' function producing invalid SQL

oops, sorry, I'll try again (and copy/paste as well)...

<class>

<name>inventory_item</name>

<variable>
<name>notes</name>
<type>text</type>
<optional>1</optional>
</variable>

<variable>
<name>mandatory</name>
<type>boolean</type>
</variable>

<variable>
<name>shared</name>
<type>boolean</type>
</variable>

<variable>
<name>calculation</name>
<type>text</type>
<optional>1</optional>
</variable>

<variable>
<name>sort</name>
<type>integer</type>
<optional>1</optional>
</variable>

<variable>
<name>description</name>
<type>text</type>
<optional>1</optional>
</variable>

<variable>
<name>grams</name>
<type>integer</type>
<optional>1</optional>
</variable>



<variable>
<name>item</name>
<class>item</class>
</variable>

<variable>
<name>inventory</name>
<class>inventory</class>
</variable>



<function>
<name>save</name>
<type>persist</type>
</function>

<function>
<name>delete</name>
<type>delete</type>
</function>

<function>
<name>validate</name>
<type>validate</type>
<parameters>
<errorcode>
<argument>errorcode</argument>
</errorcode>
</parameters>
</function>

<function>
<name>set_inventory</name>
<type>setreference</type>
<parameters>
<variable>inventory</variable>
<reference>
<argument>inventory</argument>
</reference>
</parameters>
</function>

<function>
<name>set_item</name>
<type>setreference</type>
<parameters>
<variable>item</variable>
<reference>
<argument>item</argument>
</reference>
</parameters>
</function>

<function>
<name>get_inventory</name>
<type>getreference</type>
<parameters>
<variable>inventory</variable>
</parameters>
</function>

<function>
<name>get_item</name>
<type>getreference</type>
<parameters>
<variable>item</variable>
</parameters>
</function>

</class>





On 20/09/2008, at 8:42 AM, Manuel Lemos wrote:

> 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?
>
> --
>
> 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/
>
>



========================================================
NIK SANDS - Systems Administrator, IT Services, University of
Tasmania, Australia
Phone: +61-3-63243732 (BH)
AIM / iChat: brassnix





========================================================
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]




Fri Sep 19, 2008 10:52 pm

nixanz
Offline Offline
Send Email Send Email

Forward
Message #545 of 553 |
Expand Messages Author Sort by Date

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...
nixanz
Offline Send Email
Sep 19, 2008
4:18 am

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...
Manuel Lemos
mallemos
Offline Send Email
Sep 19, 2008
4:24 am

it is optional: ... <variable> <name>grams</name> <type>integer</type> <optional>1</optional> </variable> ... It is being assigned immediately before the...
Nik Sands
nixanz
Offline Send Email
Sep 19, 2008
4:33 am

Hello, ... 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 ...
Manuel Lemos
mallemos
Offline Send Email
Sep 19, 2008
4:35 am

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...
Nik Sands
nixanz
Offline Send Email
Sep 19, 2008
4:48 am

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),...
Nik Sands
nixanz
Offline Send Email
Sep 19, 2008
5:01 am

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)) ... ...
Manuel Lemos
mallemos
Offline Send Email
Sep 19, 2008
6:23 am

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...
Nik Sands
nixanz
Offline Send Email
Sep 19, 2008
7:25 am

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...
Manuel Lemos
mallemos
Offline Send Email
Sep 19, 2008
7:47 am

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...
Nik Sands
nixanz
Offline Send Email
Sep 19, 2008
9:39 am

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,...
Manuel Lemos
mallemos
Offline Send Email
Sep 19, 2008
8:44 pm

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...
Nik Sands
nixanz
Offline Send Email
Sep 19, 2008
10:25 pm

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 ...
Manuel Lemos
mallemos
Offline Send Email
Sep 19, 2008
10:42 pm

oops, sorry, I'll try again (and copy/paste as well)... <class> <name>inventory_item</name> <variable> <name>notes</name> <type>text</type> ...
Nik Sands
nixanz
Offline Send Email
Sep 19, 2008
10:52 pm

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...
Manuel Lemos
mallemos
Offline Send Email
Sep 20, 2008
1:45 am

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...
Nik Sands
nixanz
Offline Send Email
Sep 20, 2008
4:11 am

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)) { ...
Manuel Lemos
mallemos
Offline Send Email
Sep 20, 2008
4:51 am

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 ...
Nik Sands
nixanz
Offline Send Email
Sep 20, 2008
5:13 am

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...
Manuel Lemos
mallemos
Offline Send Email
Sep 20, 2008
5:16 am

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...
Nik Sands
nixanz
Offline Send Email
Sep 20, 2008
5:20 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help