+ Reply to Thread
Results 1 to 4 of 4
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
  1. #1
    jlowtek is offline Junior Member
    Join Date
    Jul 2009
    Posts
    2

    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!

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    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

  3. #3
    jlowtek is offline Junior Member
    Join Date
    Jul 2009
    Posts
    2
    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;
    }

  4. #4
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    I think to do the proper cross object queries like this now, you need PHP 5.3 +

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.2