Results 1 to 7 of 7

Thread: where i can see the query that insert / update records in tables?

  1. #1
    Artioli is offline Junior Member
    Join Date
    May 2006
    Posts
    3

    Red face where i can see the query that insert / update records in tables?

    Hi all, I'm developing a site with sugar, and a server in java that syncronize a MySQL database with a program for handheld (pocket pc) in visual basic.

    Now I have to save the new record insert in VB program in the same tables of sugar, but I see that ID is a string of 34 chars and i need to see how the query is constructed....

    Any Help?

  2. #2
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,101

    Default Re: where i can see the query that insert / update records in tables?

    Hi,

    take a look in:

    <SUGAR-INSTALL-DIR>/include/utils.php

    at the procedure: create_guid()

    However, to work from a remote application it is FAR FAR simpler to use the SOAP API - it'll handle all the record creation for you etc. There are docs on the download site - and in these forums. But this site is good for describing the API. (It's version 3.5 but it's hardly changed if at all in the API definitions).

    http://www.jrabbit.com/Hosting/Sugar...hp?method=home

  3. #3
    Artioli is offline Junior Member
    Join Date
    May 2006
    Posts
    3

    Red face Re: where i can see the query that insert / update records in tables?

    thank for your great help!

    But sorry for my very little experince, it's all the morning that i try to connect java and sugar via soap but I dont' understant what I have to insert as targetObjectURI and header...

    Can you send me some links with examples of connection from some language and sugar?


    this example:

    <soap:Envelope
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:mrns0="http://www.sugarcrm.com/sugarcrm"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <mrns0:test>
    <string xsi:type="xs:string">Hello</string>
    </mrns0:test>
    </soap:Body>
    </soap:Envelope>


    how you send this file for example in php, or if you know, in java?

    thank

  4. #4
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,101

    Default Re: where i can see the query that insert / update records in tables?

    Hi,

    I'm afraid I'm not a java programmer so cannot provide examples there - but here's some PHP.

    You need to include some kind of SOAP interface code - Sugar themselves use nusoap - so I used the same for our mods.

    For the 'test' code you posted you could do something like the following:

    Code:
    <?php
    
    require_once('C:\Program Files\Apache Group\Apache2\htdocs\sugarcrm\include\nusoap\nusoap.php');
    $client = new nusoapclient('http://localhost/sugarcrm/soap.php');
    
    $param1 = "Hello World!";
    $result = $client->call('test',$param1);
    ?>

    A more complex - but not very elegant - real world application would be like:

    Code:
    #!/php/php.exe
    <?php
    
    $GLOBALS['sugarEntry'] = true;
    
    require_once('C:\Program Files\Apache Group\Apache2\htdocs\sugarcrm\include\nusoap\nusoap.php');
    $client = new nusoapclient('http://localhost/sugarcrm/soap.php');
    $client->debug_flag=true;
    
    //LOGIN (array-based parameter structure for the soap call)
    $a1 = "A_USERNAME";
    $a2 = "3456f2b06265498g54333bff4e1234567";
    $a3 = ".01";
    $p1 = array(
                    'user_name' => $a1,
                    'password' => $a2,
                    'version' => $a3
                    );
    
    $result = $client->call('login',array('parameters' => $p1));
    $sessionId = $result[id];
    ..
    ..
    ..
    
    
    //execute select query on 'users' table to select those with give email address.
    $aa1 = $sessionId;
    $aa2 = "Users";
    $aa3 = "email1 = '".$userEmail."' OR email2 = '".$userEmail."'";
    $aa4 = "";
    $aa5 = 0;
    $aa6 = array('user_name');
    $aa7 = 0;
    //a more complex array structure
    $pp1 = array(
                    'session' => $aa1,
                    'module_name' => $aa2,
                    'query' => $aa3,
                    'order_by' => $aa4,
                    'offset' => $aa5,
                    'select_fields' => $aa6,
                    'max_results' => $aa7
                    );
    $queryresult = $client->call('get_entry_list', $pp1);
    
    ..
    ..
    ..
    
    //LOGOUT (simple string based call)
    $param1 = $sessionId;
    $result = $client->call('logout',$param1);
    
    
    
    ?>
    Doesn't include error checking - usually part of the data structure returned in the result. Eg. for the login:

    Code:
    ..
    ..
    $result = $client->call('login',array('parameters' => $p1));
    if($result[error][number]!='0') {
            myLoggingCode($result[error][description]);
            Die;
    }

  5. #5
    default is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    102

    Default Re: where i can see the query that insert / update records in tables?

    you can see it by having trying to put a code on mssql/mysql manager.php on the query function and write the query in a txt file .. there you can see all the query that have been used..

    and by the way .. every module has its own way of generating query..
    Last edited by default; 2011-03-17 at 04:44 PM.

  6. #6
    Join Date
    Feb 2007
    Location
    San Jose, CA
    Posts
    1,169

    Default Re: where i can see the query that insert / update records in tables?

    Hi default,

    Yes, that's true, but I want to emphasize again the need to use the SOAP API for accessing the Sugar database. That's the preferred way to build integrations.
    Susie Williams

  7. #7
    mapm's Avatar
    mapm is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    Portugal
    Posts
    239

    Default Re: where i can see the query that insert / update records in tables?

    Quote Originally Posted by Artioli
    Hi all, I'm developing a site with sugar, and a server in java that syncronize a MySQL database with a program for handheld (pocket pc) in visual basic.

    Now I have to save the new record insert in VB program in the same tables of sugar, but I see that ID is a string of 34 chars and i need to see how the query is constructed....

    Any Help?
    If you enable logging for debuging(log4php.properties) you will see all queries and lot of information in sugarcrm.log this is a good way to understand and debug the way sugar works.

    You can do integration in many ways but the best way is allways by "the book" (soap api)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •