This is a discussion on how to search on multiple objects within the Salesforce PHP Tutorials forums, part of the Salesforce category; Hi Mike,
Great site! I hope you can help me with my
-
how to search on multiple objects
Hi Mike,
Great site! I hope you can help me with my issue. I have 3 objects (address, city, state) under table Contacts and I want to be able to search on them just like how the SOSL search.
ADDRESS ----|--- CITY -------|-- STATE
-------------+----------------+-----------
1 wilshire ----|-- los angeles --|-- CA
624 s grand --|-- los angeles --|-- CA
1 wilshire ----|-- austin -------|-- TX
If I search for '1 wilshire CA' It should display 1 record.
Is this possible using SOQL query? Or should I use SOSL instead? What should be the PHP code and query to display if I were to use SOSL?
Appreciate your inputs in advance. Thanks!
-
sorry for the delay in replying, I have been busy and not able to be here as much as I would like.
Using PHP to search Salesforce is not the best method, but i believe it id doable. Is there a chance that you could post some of your code/
~Mike
-
Hi Mike,
Below is my code for getting records. The problem with my SOQL query is that i'm not able to search on multiple objects. If I search for '1 wilshire CA' i'm not getting any result.
Is there a workaround using SOQL. I heard that this is possible using SOSL only but I'm not sure how to do the coding using SOSL in PHP.
function getRecords($connection) {
$query_text = $_POST['txtSearch'];
$query = "Select o.Address__c, o.City__c, o.State__c, o.Zip__c from Building__c o where o.Address__c like '%$query_text%' or o.City__c like '%$query_text%' or o.State__c like '%$query_text%'";
$queryOptions = new QueryOptions(200);
$response = $connection->query(($query), $queryOptions);
if ($response->size > 0)
{
$records = $response->records;
while (!$response->done)
{
set_time_limit(100);
$response = $connection->queryMore($response->queryLocator);
}
}
return $response->records;
}
-
I think to do the proper cross object queries like this now, you need PHP 5.3 +
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Bookmarks