Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL query code using the OR for two different fields with Web Service
    primarykey
    data
    text
    <p>Normally I can figure this out, but the format looks a bit different then what I am used to. I have a web service using php with CodeIgnighter. The function looks like this:</p> <pre><code> function getCurrentSales($office_id) { $CI =&amp; get_instance(); $CI-&gt;load-&gt;model("properties"); //Get the properties $where = array('field_SaleOfficeCode'=&gt;$office_id); $where = array('field_ListOfficeCode'=&gt;$office_id); $result = $CI-&gt;properties-&gt;getCurrentSales($where); $properties = $result-&gt;result_array(); foreach($properties as $p){ //Get property images $where = array('ListingKey'=&gt;$p['UniqueKey']); $property_arr[] = $p; } return $property_arr; } $this-&gt;nusoap_server-&gt;service(file_get_contents("php://input")); } </code></pre> <p>What I am trying to do is return rows where <code>field_ListOfficeCode</code> or <code>field_ListOfficeCode</code> have the value of <code>$office_id</code>. As it is now, only when <code>field_ListOfficeCode=&gt;$office_id</code>, not when one or the other equals the value.</p> <p>Models Method Code:</p> <pre><code>function getCurrentSales($where = null) { $this-&gt;db-&gt;select('field_ListingKey as UniqueKey, field_LocaleListingStatus as Status, field_CloseDate as ClosingDate, field_ContractDate as ContractDate, field_ListingID as MLS, TRIM("#VARIES" from field_FullStreetAddress) as StreetAddress, field_ListPrice as Price, field_ListOfficeCode as BrokerID, if(field_Beds != "", field_Beds, 0) as NumBeds, if(field_BathsFull != "", field_BathsFull, 0) as NumFullBaths, if(field_BathsHalf != "", field_BathsHalf, 0) as NumHalfBaths, field_InternetRemarks as PropertyRemarks, field_ListOfficeName as ListingOfficeName, field_ListPicture3URL as MainPhoto, CONCAT(field_ListAgentNickname, " ", field_ListAgentLastName, " ", (if(field_ListAgentNameSuffix = "NULL", field_ListAgentNameSuffix, ""))) as ListingAgent, CONCAT(field_SaleAgentNickname, " ", field_SaleAgentLastName, " ", (if(field_SaleAgentNameSuffix = "NULL", field_SaleAgentNameSuffix, ""))) as SalesAgent, CONCAT(field_City, ", ", field_State, " ", field_PostalCode) as AreaAddress', false); $this-&gt;db-&gt;from('TABLE_2'); if($where != null){ $this-&gt;db-&gt;where($where, false); $this-&gt;db-&gt;where('YEAR(field_ContractDate) = YEAR(NOW())', NULL, false); $this-&gt;db-&gt;where('MONTH(field_ContractDate) = MONTH(NOW())', NULL, false); } $this-&gt;db-&gt;order_by('ContractDate', 'desc'); //get random row //$this-&gt;db-&gt;limit($limit); $query = $this-&gt;db-&gt;get(); return $query; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload