php - how can define table record is exiest or not in table in database using db-table in zend -


i using zend framework. want define product name exist or not if not insert product name.

i using code in controller

$this->product_tbl = new application_model_dbtable_producttbl();  $product_name = 'mobile';  $productresult = $this->product_tbl->fetchrow($this->product_tbl->select()->where('product_name ='.$product_name));   if(!$productresult){                          // when productresult null  }  message: sqlstate[42s22]: column not found: 1054 unknown column 'mobile' in 'where clause'  

my question if product_name not found display simple message "row not found"

$this->product_tbl = new application_model_dbtable_producttbl(); // project db table  $product_name = 'mobile'; // project_name variable declare , store value 'mobile'  $productresult = $this->product_tbl->fetchall($this->product_tbl->select()->where('product_name = ?', $product_name)); // fetch result , store in $productresult  $row = $productresult->current(); // set current()  if($row == null){          echo "row null"; } 

i user current() function return null value when $productresult have no value...


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -