php - Doctrine does not return null for NULL values when you use get magic methods -


i have symfony application configured doctrine, , have designed one-to-many relationship between 2 models: item belongs customer, alias sfguarduser.

let's there situations item not have customer. test i'm trying make comparison:

$customer = $this->getcustomer(); if ( $customer ) {   return $customer->getnbinvoices(); } else {   return 'n/a'; } 

however $this->getcustomer() not return null or other 'false' value compare with, , foreign key set null in database.

how can compare object not store actual value in database?

i think $this->getcustomer() return blank instance of customer doctrine_record. can test if customer has id, or can use method of doctrine_record class exists() :

if($customer->exists()){  code... } 

http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_record.html#exists%28%29


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -