php - Zend DB: null values -
i appreciate if 1 explain why query returning null values. this query works fine when use fetchrow() method.
public function getcustomerrowwithaddress($customer_id) { $select = $this->select()->setintegritycheck(false); $select->from('irh_tv.irh_site_location sl', array('name location_name', 'start_date', 'end_date', 'service_pack_id', 'stb_id')); $select->joinleft('irh_tv.irh_customers c', 'c.customer_id = sl.customer_id , c.active = 1 , c.site_id = sl.site_id', array('customer_id','surname', 'title', 'site_id', 'first_name', 'company', 'business_no', 'home_no', 'mobile_no', 'email', 'address_id')); $select->joinleft('irh_tv.tv_stb_data tv', 'tv.site_id = sl.site_id , sl.stb_id = tv.id', array('user_id mac_address')); $select->joinleft('irh_tv.irh_address ad', 'c.address_id = ad.id', array('address_line1', 'address_line2', 'town', 'county', 'country', 'postcode')); $select->where("sl.customer_id = $customer_id"); //if($_request['d'] == 1) { echo $select; } _syslog($select); //$_rows = $this->fetchrow($select); $_rows = $this->fetchall($select); return $_rows; }
edit:
i try access rowset so:
$model = _getmodel(); $table = $model->gettable("irh_customers"); $customer_address_row = $table->getcustomerrowwithaddress($id); //$customer_address_row = $table->getcustomerrowswithaddress($id); //$this->_row = $customer_address_row ? $customer_address_row : $table->getrowbyid($id); $row_count = count($customer_address_row); if($row_count > 0){ ///$rows = $this->_row->toarray(); $this->exists = true; $this->id = $id; if($row_count > 1){ //$array = $customer_address_row->toarray(); foreach($customer_address_row->toarray() $row){ foreach($row $k => $v){ //if($k != 'stb_id' || $k != 'mac_address'){ if(!isset($this->k[$k])){ $this->k[$k] = $v; } /*}else if($k == 'stb_id'){ $this->k['stb_id'][] = $v; } else if($k == 'mac_address'){ $this->k['mac_address'][] = $v; }*/ } } }else{ foreach($customer_address_row->toarray() $k => $v) { _syslog($v); $this->k[$k] = $v; } } }
fetchrow() returns object of zend_db_table_row_abstract. fetchall() returns array.
Comments
Post a Comment