Thanks Herman,

>> If you can explain it to your customers,
Actually I am not creating a commercial script to sell nor I am selling
something via the script I am making. Actually I am just educating myself
with php programming, practice and trying to learn for myself.
I don't understand why an invoice should be issued without order, but I see
almost all invoice systems has the ability to assign an invoice to client
without order! so I got the question how this is possible since the
relation is ManyToOne to order... and I learnt something new that FK can be
null for this purpose...



On Sun, May 4, 2014 at 8:07 PM, Herman Peeren <[email protected]>wrote:

> Yes:you can define that the foreign key order_id can be NULL. You have to
> do it both in the database table definition and in the mapping. Don't know
> exactly where to put it in the mapping via php, as you do, in MapField( )
> or in mapOneToMany( ), but somewhere you can define nullable =true (without
> quotes).
>
> Good practice or not to do that? Depends on the domain you are modeling:
> if you can have invoices without an order, then the order can be NULL. If
> you can only have invoices when you have an order, then is the order cannot
> be NULL. It depends on how you define an order and an invoice. I personally
> don't pay any invoices where I don't get anything in return that I have
> ordered, but you can make other definitions of orders and invoices, of
> course. Try to be as clear as possible. If you can explain it to your
> customers, then it must be doable to make a mapping.
>
> Another possibility I mentioned is using an empty order for this, a kind
> of dummy order. This is the Null-Object pattern:
> http://en.wikipedia.org/wiki/Null_Object_pattern . The advantage of using
> it is that in some cases where you normally would have a conditional to
> check if there is an order or not, you now have an order (only empty).
>
> And of course you can also say: an order can induce recurring orders; and
> then there is only one invoice for each order (or none, in case you want a
> "standalone invoice").
>
> On Sunday, 4 May 2014 16:43:35 UTC+2, Parsifal wrote:
>>
>> Thanks Herman,
>> Can you please clarify it with example how can I have a null order
>> object? Or how to have a nullable coloumn? Do you mean if the fk of
>> order_id in invoice will be nullable, then this is possible to have an
>> invoice without order?
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to