$products = Products::model()->findAll(); foreach($products as $product) { echo $product->id; .... .... } fetch rows by condition example $condition = array('condition'=>"id in (1,2,3)"); $products = Products::model()->findAll($condition); the above line fetch product rows that have id 1,2,3. fetch single Row $product = Products::model()->findByPk(1); the above line fetch row that have primary key (here id) is 1. then $product->product_name will display the product_name attribute value.
No comments:
Post a Comment