Last active
January 29, 2016 14:54
-
-
Save dmulvi/8f44c682a7d33a691fdf to your computer and use it in GitHub Desktop.
Basic code for a custom importer to sugarcrm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $db; | |
if (($handle = fopen('/var/www/html/crm/custom/ninjacode/nvw-contacts.csv', 'r')) !== FALSE) { | |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | |
$sql = "UPDATE contacts c | |
INNER JOIN contacts_cstm cc ON cc.id_c = c.id | |
SET c.first_name = '$data[1]', | |
cc.preferred_name_c = '$data[2]', | |
c.last_name = '$data[3]'"; | |
if (!empty($data[4])) { | |
$sql .= ", | |
c.primary_address_street = '$data[4]', | |
c.primary_address_city = '$data[6]', | |
c.primary_address_state = '$data[8]', | |
c.primary_address_country = '$data[7]'"; | |
} | |
$sql .= " WHERE cc.unique_id_c = '$data[0]'"; | |
echo $sql.'<br/>'; | |
$db->query($sql); | |
} | |
fclose($handle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment