+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 24

Thread: Null values inserting into database

  1. #11
    msweet is offline Junior Member
    Join Date
    Sep 2008
    Location
    Gold Coast, Australia
    Posts
    10
    Hi Mike!

    Thanks for replying, here are some of the results - there are 856 of them so I only pasted the first few.

    regards,
    Matt

    Property Table Truncated

    Array
    (
    [id] =>
    )

    Warning: Invalid argument supplied for foreach() in /home/investme/public_html/phptoolkit/sync.php on line 135
    Array
    (
    [id] =>
    )

    Warning: Invalid argument supplied for foreach() in /home/investme/public_html/phptoolkit/sync.php on line 135
    Array
    (
    [id] =>
    )

  2. #12
    msweet is offline Junior Member
    Join Date
    Sep 2008
    Location
    Gold Coast, Australia
    Posts
    10
    Hi Mike,

    I made a mistake here, yesterday I removed the "id" from the soql query to do some tests.

    here is the "fixed" error... lol!

    Property Table Truncated
    Array
    (
    [id] => a
    )

    Warning: Invalid argument supplied for foreach() in /home/investme/public_html/phptoolkit/sync.php on line 135
    Array
    (
    [id] => a
    )

    Warning: Invalid argument supplied for foreach() in /home/investme/public_html/phptoolkit/sync.php on line 135
    Array
    (
    [id] => a
    )

    Warning: Invalid argument supplied for foreach() in /home/investme/public_html/phptoolkit/sync.php on line 135
    Array
    (
    [id] => a
    )

  3. #13
    msweet is offline Junior Member
    Join Date
    Sep 2008
    Location
    Gold Coast, Australia
    Posts
    10
    Hi Mike,

    Here is a sample block I created by uncommenting line 67 and 68 "For Debugging" code in the script:

    Code:
    Property Table Truncated
    QueryResult Object
    (
        [queryLocator] => 
        [done] => 1
        [records] => Array
            (
                [0] => SObject Object
                    (
                        [type] => Property__c
                        [fields] => stdClass Object
                            (
                                [OwnerId] => 00520000000lIeuAAE
                                [IsDeleted] => false
                                [Name] => CBD on Broadwater 6
                                [CreatedDate] => 2008-03-04T02:11:56.000Z
                                [CreatedById] => 00520000000lIeuAAE
                                [LastModifiedDate] => 2008-07-04T05:18:28.000Z
                                [LastModifiedById] => 00520000000lIepAAE
                                [SystemModstamp] => 2008-07-04T05:18:28.000Z
                                [LastActivityDate] => 
                                [Unit_lot_number__c] => 6
                                [Includes_Furniture__c] => false
                                [Purchase_Price__c] => 217000.0
                                [Status__c] => Sold
                                [Development_Project__c] => a082000000CMipgAAD
                                [Number_of_bedrooms__c] => 
                                [Number_of_bathrooms__c] => 
                                [Number_of_car_park_spaces__c] => 
                                [Deposit__c] => 0.0
                                [Anticipated_Rent__c] => 
                                [Council_Rates__c] => 
                                [Body_Corporate_Fees__c] => 
                                [Commission_at_unconditional__c] => 
                                [Commission_at_settlement__c] => 
                                [Type__c] => Unit
                                [Gross_Rental_Yield__c] => 0.0
                                [Level__c] => 
                                [Internal_Living_Area__c] => 
                                [External_Living_Area__c] => 
                                [Storage__c] => false
                                [study__c] => false
                                [Media_Room__c] => false
                                [Block_Size__c] => 
                                [Building__c] => 
                                [Floor_Plan__c] => 
                                [Curtains_and_Blinds__c] => false
                                [Window_Screens__c] => false
                            )
    
                        [Id] => a0A20000001ADBiEAO
                    )

  4. #14
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    Matt

    do you use IM or Skype? Are you in Australia?
    ~Mike

  5. #15
    msweet is offline Junior Member
    Join Date
    Sep 2008
    Location
    Gold Coast, Australia
    Posts
    10
    Hi Mike,

    My skype name is matthewsweet

    I would love to chat!

    Yes, in OZ.

    regards,

    Matt

  6. #16
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    hey Matt I saw that you left me a message on Skype the other day, did you need something man?

  7. #17
    Alex is offline Junior Member
    Join Date
    Apr 2009
    Posts
    4
    Also thanks for a great tool.
    I'm having the same problem as well and can not figure this out.

    get_records:
    Code:
    <strong>Account Table Truncated</strong><br /><pre>QueryResult Object
    (
        [queryLocator] => 01g70000003vGKcAAM-200
        [done] =>
        [records] => Array
            (
                [0] => SObject Object
                    (
                        [type] => Account
                        [fields] => stdClass Object
                            (
                                [IsDeleted] => false
                                [MasterRecordId] =>
                                [Name] => Acme
                                [Type] => Prospect
                                [ParentId] =>
                                [BillingStreet] => 1012 Main Rd.
                                [BillingCity] => New York
                                [BillingState] => NY
                                [BillingPostalCode] => 31349
                                [BillingCountry] => USA
                                [ShippingStreet] => 1012 Main Rd.
                                [ShippingCity] => New York
                                [ShippingState] => NY
                                [ShippingPostalCode] => 31349
                                [ShippingCountry] => USA
                                [Phone] => (212) 555-5555
                                [Fax] => (212) 555-5555
                                [Website] =>
                                [Industry] => Manufacturing
                                [AnnualRevenue] => 1.0E8
                                [NumberOfEmployees] => 680
                                [Description] =>
                                [OwnerId] => 005700000011o0DAAQ
                                [CreatedDate] => 2007-06-23T00:51:51.000Z
                                [CreatedById] => 005700000011o0DAAQ
                                [LastModifiedDate] => 2007-06-23T00:51:51.000Z
                                [LastModifiedById] => 005700000011o0DAAQ
                                [SystemModstamp] => 2007-07-23T05:00:38.000Z
                                [LastActivityDate] =>
                                [Server_Farm__c] =>
                                [Partner_Site_ID__c] =>
                                [Account_Created_by_Service__c] => false
                                [Customer_ID__c] => 00060250
                                [Account_Confirmed_by_Service__c] => false
                                [Number_of_EA_Audits__c] =>
                                [MRR__c] =>
                                [Related_Fields__c] =>
                                [Customer_ID_Group__c] =>
                                [Sales_Rep__c] =>
                                [Account_Manager_Rep__c] =>
                                [Account_Priority__c] =>
                                [LHQ_Org_ID__c] =>
                                [Active__c] => false
                                [Contract_IDs__c] =>
                                [Weekly_Reported__c] => false
                                [Dedicated_IP__c] =>
                                [Account_Product_Group__c] =>
                            )
    
                        [Id] => 0017000000KRjRHAA1
                    )
    store_in_db:
    Code:
    <strong>Account Table Truncated</strong><br /><pre>Array
    (
        [id] => 0
    )
    </pre>
    Warning: Invalid argument supplied for foreach()
    Thanks in advance for any guidance.

  8. #18
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    Alex,

    First thanks for joining the site. When I worked with Matt on his issue it was a difference in the phptoolkit. I can surely help you, but I need to see your code if you do not mind.

    Please make sure that you place the code between php tags by clicking on the little php icon in the WYSIWYG editor above:


    Thanks

    ~Mike

  9. #19
    Alex is offline Junior Member
    Join Date
    Apr 2009
    Posts
    4
    Sure. Thanks Mike. It is the script you provided here is is just in case.
    PHP Code:
    <?php
    ini_set
    ("soap.wsdl_cache_enabled","0");


    require_once (
    './includes/soapclient/SforcePartnerClient.php');

    /***************************************************************************** 
    *  This script uses ADODb, you must have ADOdb installed or in a common      *
    *  folder to run this script.  The best way to do this is to go to           *
    *  http://adodb.sourceforge.net/ and download the latest version and install *
    *  it in your include_path in the php.ini file.                              *
    ******************************************************************************/
    require_once ('./includes/adodb.inc.php'); 
     
    $db NewADOConnection('mysql');


    //MySQL database connection information
    $db->Connect("localhost","sfmysql","sfmysql","sf_live");

    //Truncate current database to establish a refresh
    $sql "TRUNCATE TABLE sf_lyris_live_account";
    if (
    $db->Execute($sql)) echo "<strong>Account Table Truncated</strong><br />";

    //Salesforce Connection information
    $wsdl './includes/soapclient/partner.wsdl.xml';
    $userName "myuser";
    $password "mypass";


    //setup connection
    $client = new SforcePartnerClient();
    $client->createConnection($wsdl);
    $loginResult $client->login($userName,$password);

    //SOQL query for Object in Salesforce
    //$soql = "Select Id, IsDeleted, MasterRecordId, Name, Type, ParentId, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, Phone, Fax, AccountNumber, Website, Sic, Industry, AnnualRevenue, NumberOfEmployees, Ownership, TickerSymbol, Description, Rating, Site, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, Account_Description__c, Area__c, End_Equipment__c, FY_CY_Auto_Info__c, FY_CY_Automotive__c, FY_CY_Communications__c, FY_CY_HSSP__c, SA_ID__c, FY_CY_Info_Comm__c, FY_CY_ISP__c, FY_CY_Micros__c, FY_CY_Mixed_Signal_1__c, FY_CY_Mixed_Signal_2__c, FY_CY_MM__c, FY_CY_Notebook__c, FY_CY_Optocon__c, FY_CY_SPC__c, FY_CY_SPM__c, FY_CY_SSIP__c, FY_CY_Thermal_Battery__c, FY_CY_Total_Design__c, FY_CY_Total_Purchasing__c, FY_CY_Wireless__c, Inactive__c, maxim_id__c, Region__c, Status__c, WebID__c FROM Account";

    $soql "Select Id, IsDeleted, MasterRecordId, Name, Type, ParentId, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, Phone, Fax, Website, Industry, AnnualRevenue, NumberOfEmployees, Description, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, Server_Farm__c, Partner_Site_ID__c, Account_Created_by_Service__c, Customer_ID__c, Account_Confirmed_by_Service__c, Number_of_EA_Audits__c, MRR__c, Related_Fields__c, Customer_ID_Group__c, Sales_Rep__c, Account_Manager_Rep__c, Account_Priority__c, LHQ_Org_ID__c, Active__c, Contract_IDs__c, Weekly_Reported__c, Dedicated_IP__c, Account_Product_Group__c FROM Account";

    //Processes the query to get account information from Salesforce
    $records get_records($client,$soql,$db);

    if (
    $records === false)
    {
        
    //mail("mike.simonds@maxim-ic.com","PHP Product2 Script  Error","There has been an error in the product2 replication script\nPlease Check Script");
    }
    echo 
    '<p>There are currently '.$records.' products:</p>';

    $today date("F j, Y, g:i a");
    $end 'Product2 Import script ended at '.$today.' and inserted '.$records.' into the database';


    function 
    get_records($connection,$query,$db)
    {

        
    //Set this to the number of records to process per batch
        //200 is the minimum
        
    $queryOptions = new QueryOptions(200);
        
    $connection->setQueryOptions($queryOptions);

        
    $response $connection->query(($query),$queryOptions);

        
    //for debugging
        //echo '<pre>' . print_r($response,true) . '</pre>';
        //exit;

        
    if ($response->size 0)
        {
            
    $records $response->records;
            
    // Cycles through additional responses if the number of records// exceeds the batch size
            
    $count_records 0;
            while (!
    $response->done)
            {
                
    $records $response->records;
                
    set_time_limit(100);
                
    ini_set("memory_limit","512M");


                
    //Process curent $records
                
    $current_count store_in_db($records,$db);

                if (
    $current_count === false)
                {
                    return 
    false;
                }
                else
                {
                    
    $count_records += $current_count;
                }
                echo 
    "processed ".$count_records." records<br />";
                
    flush();

                
    $response $connection->queryMore($response->queryLocator,$queryOptions);


            }
            
    set_time_limit(100);
            
    $records $response->records;
            
    //Process curent $records

            //store the last set of records into the database
            
    $current_count store_in_db($records,$db);

            if (
    $current_count === false)
            {
                return 
    false;
            }
            else
            {
                
    $count_records += $current_count;
            }
        }

        return 
    $count_records;
    }

    /*Function to store records into
    * database in chunks of the $queryOptions = new QueryOptions(200);*/
    function store_in_db($records,$db)
    {
      
        
    $record_count count($records);
        
    //echo $record_count;
        
    $rows_loaded 0;

        for (
    $i 0$i $record_count$i++) //foreach ($records as $r)
        
    {
            
    $r = new SObject($records[$i]);
            
    //echo '<pre>' . print_r($r,true) . '</pre>';  
            
    $pass_this['id'] = $r->Id;

            
    //echo '<pre>' . print_r($pass_this,true) . '</pre>';  
            
    foreach ($r->fields as $key => $value)
            {
                
    $pass_this[$key] = addslashes($r->fields->$key);
            }


            
    $fields implode(",",array_keys($pass_this));
            
    $values implode("','",array_values($pass_this));
            
            
    $query "INSERT INTO sf_lyris_live_account (".$fields.") VALUES ('".$values."')";
            
            
            
    //executes and loads data coming from salesforce into table
            
    if ($db->Execute($query))
            {
                
    $rows_loaded++;
            }
            else
            {
                echo 
    $db->ErrorMsg()."<br />";
                return 
    false;
            }
            
    //exit;
        
    }
        return 
    $rows_loaded;

    }

    ?>

  10. #20
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    So you have not changed anything in the file? what version of the toolkit are you using? That will answer a lot


    ~Mike

+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast

Tags for this 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.1