-
-
Notifications
You must be signed in to change notification settings - Fork 23
Looking for an existing entry
Zhmayev Yaroslav edited this page Nov 30, 2017
·
1 revision
Check if a contact record exists, by using the first and the last name as constraints. If there is a John Smith among your contacts the code below will print out only some fields (listed below). This is useful when you don't need all the information available.
// Look for John Smith in Contacts
// and print out only some fields
$johnSmith = $client->entities->findOne('Contacts', [
'firstname' => 'John',
'lastname' => 'Smith',
], [
'id',
'salutationtype',
'firstname',
'lastname',
'email',
'phone'
]);
if (false !== $johnSmith) {
print_r($johnSmith);
} else {
echo('John Smith\'s record doesn\'t exists!' . PHP_EOL);
}
// The output
Array
(
[id] => 12x3
[salutationtype] => Mr.
[firstname] => John
[lastname] => Smith
[email] => [email protected]
[phone] => +103030303
)