php - Multiple objects per array row -


i'm trying create api , need put multiple queries json ouput, issue returned object of class stdclass... here code:

$querystr = "select  entry_id id {$wpdb->prefix}connections_term_relationships term_taxonomy_id = '{$_get['catid']}'";      $cid = $wpdb->get_results($querystr);       $dircount=count($cid);     $arraycategory= array();     $androidarray = array();      if($dircount > 0){         foreach($cid $company){             $querycinfo = "select id, organization, contact_first_name, contact_last_name, bio  {$wpdb->prefix}connections id = '{$company->id}'";              $companyinfo = $wpdb->get_row($querycinfo);             $queryaddress = "select  line_1, line_2, line_3, state, zipcode {$wpdb->prefix}connections_address entry_id = '{$company->id}'";              $address = $wpdb->get_row($queryaddress);             $queryemail = "select  address  {$wpdb->prefix}connections_email entry_id = '{$company->id}' , type = 'work'";              $email = $wpdb->get_row($queryemail);             $querywebsite = "select  title, url  {$wpdb->prefix}connections_link entry_id = '{$company->id}' , type = 'website'";              $website = $wpdb->get_row($querywebsite);             $queryphone = "select number {$wpdb->prefix}connections_phone entry_id = '{$company->id}' , type = 'workphone'";              $phone = $wpdb->get_row($queryphone);           $arraycategory[]= $companyinfo;           }     }else{         $arraycategory[0]=array('organization'=>'no company found within category');     }      $androidarray = array('companies'=>$arraycategory); echo json_encode($androidarray); } 

i need $arraycategory hold more $companyinfo, need hold other variables well. being built wordpress. in advance!

i ended formatting sql query in matter made more sense:

$querycinfo = "select main.id, organization, contact_first_name, contact_last_name, bio, number  {$wpdb->prefix}connections main             join {$wpdb->prefix}connections_phone phone on phone.entry_id = main.id , main.id = '{$company->id}'";  

this solved issue.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -