0

i am using zend framework. i want to define product name is exist or not if not then insert the product name.

i am using this 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){

                        // do when productresult is null

}

Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mobile' in 'where clause' 

my question is if product_name is not found then display a simple message "row is not found"

1 Answers1

1
$this->product_tbl = new Application_Model_DbTable_Producttbl(); // project db table

$product_name = 'mobile'; // project_name variable declare and store value 'mobile'

$productresult = $this->product_tbl->fetchAll($this->product_tbl->select()->where('product_name = ?', $product_name)); // Fetch result and store in $productresult

$row = $productresult->current(); // set current()

if($row == NULL){

        echo "row is null";
}

i user current() function which is return null value when $productresult have a no any value...