Loading ...
Sorry, an error occurred while loading the content.

problem persist objects with null values

Expand Messages
  • pokara93
    hello, with the new version I can persist an object that have another object that it is not persisted.For example, I have I class venta (sale) that have an
    Message 1 of 5 , Oct 4, 2004
    View Source
    • 0 Attachment
      hello, with the new version I can persist an object that have another
      object that it is not persisted.For example, I have I class venta
      (sale) that have an object of a class cliente (client), but not all
      the "sales" have a "client", before new version if this object is not
      initialize and persisted put the null value and all works fine. But
      now to persist "sale" object i must to persist "client" object
      before. How can i do it that? i can't create an empty "client"
      because the "client" have another object inside and this have
      another... a chain of objects that must to be persist before ... any
      ideas?
      thank you

      pokara
    • Manuel Lemos
      Hello, ... Right, you can t tell an object to store a reference to an object that was not persisted because it does not make sense. It is explained in the
      Message 2 of 5 , Oct 4, 2004
      View Source
      • 0 Attachment
        Hello,

        On 10/04/2004 08:18 AM, pokara93 wrote:
        > hello, with the new version I can persist an object that have another
        > object that it is not persisted.For example, I have I class venta
        > (sale) that have an object of a class cliente (client), but not all
        > the "sales" have a "client", before new version if this object is not
        > initialize and persisted put the null value and all works fine. But
        > now to persist "sale" object i must to persist "client" object
        > before. How can i do it that? i can't create an empty "client"
        > because the "client" have another object inside and this have
        > another... a chain of objects that must to be persist before ... any
        > ideas?

        Right, you can't tell an object to store a reference to an object that
        was not persisted because it does not make sense. It is explained in the
        troubleshooting guide:

        http://www.meta-language.net/metastorage-troubleshooting.html#non-persisted-references

        The change in the setreference functions code was made to prevent bugs
        in your application.

        If you want the sale object to not point to any client object in some
        cases, just pass a null to the setreference function. You do not need to
        create an client object to pass it to the setreference function.

        --

        Regards,
        Manuel Lemos

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/

        PHP Reviews - Reviews of PHP books and other products
        http://www.phpclasses.org/reviews/

        Metastorage - Data object relational mapping layer generator
        http://www.meta-language.net/metastorage.html
      • pokara93
        ... some ... need to ... ok, but if i call setreference with null, when i persist the object sale and checked if isset client, the report an error:
        Message 3 of 5 , Oct 5, 2004
        View Source
        • 0 Attachment
          > If you want the sale object to not point to any client object in
          some
          > cases, just pass a null to the setreference function. You do not
          need to
          > create an client object to pass it to the setreference function.

          ok, but if i call setreference with null, when i persist the object
          sale and checked if isset client, the report an error:

          $sale->client=null;

          'it was atempted to persist an object of the class Venta with a
          required variable that is not initialized'


          if i put it as:

          $sale->setClient(null);

          don't return to me nothing ¿¿¿¿?????


          and if i put:
          $myclient=null;
          $sale->setClient($myclient);
          report:
          "it was attempted to set the cliente reference variable of class
          Venta to a null object"

          at this moment to works allright, i was create a client with null
          values and id = 0.




          any more ideas???
          thank you
        • Manuel Lemos
          Hello, ... Starting this release all variables are required by default. To be allowed to leave a variable undefined you needed to declare it as optional:
          Message 4 of 5 , Oct 5, 2004
          View Source
          • 0 Attachment
            Hello,

            On 10/05/2004 06:14 AM, pokara93 wrote:
            >>If you want the sale object to not point to any client object in
            > some
            >>cases, just pass a null to the setreference function. You do not
            > need to
            >>create an client object to pass it to the setreference function.
            >
            > ok, but if i call setreference with null, when i persist the object
            > sale and checked if isset client, the report an error:
            >
            > $sale->client=null;
            >
            > 'it was atempted to persist an object of the class Venta with a
            > required variable that is not initialized'
            >
            >
            > if i put it as:
            >
            > $sale->setClient(null);
            >
            > don't return to me nothing ¿¿¿¿?????
            >
            >
            > and if i put:
            > $myclient=null;
            > $sale->setClient($myclient);
            > report:
            > "it was attempted to set the cliente reference variable of class
            > Venta to a null object"
            >
            > at this moment to works allright, i was create a client with null
            > values and id = 0.

            Starting this release all variables are required by default. To be
            allowed to leave a variable undefined you needed to declare it as optional:

            <variable>
            <name>cliente</name>
            <class>cliente</name>
            <optional>1</optional>
            </variable>


            --

            Regards,
            Manuel Lemos

            PHP Classes - Free ready to use OOP components written in PHP
            http://www.phpclasses.org/

            PHP Reviews - Reviews of PHP books and other products
            http://www.phpclasses.org/reviews/

            Metastorage - Data object relational mapping layer generator
            http://www.meta-language.net/metastorage.html
          • pokara93
            ok!thank you very much pokara
            Message 5 of 5 , Oct 5, 2004
            View Source
            • 0 Attachment
              ok!thank you very much

              pokara
            Your message has been successfully submitted and would be delivered to recipients shortly.