Skip to content

Search in a database

By Mounir 2 min read

Search in a database.

array Recherche_BDD( login, motdepasse, bdd, champ, recherche)

Description

Search in the database bdd for rows whose field champ equals recherche.

Parameters (required)

login: customer ID (nichandle)

motdepasse: the password

bdd: the database identifier (see List databases)

champ: the name of the field to search on (see Retrieve database structure to discover the available fields)

recherche: the string to search for

Return value

An array where each row contains an array with a result. The reference of each record is provided in the pkey_id key.

Error messages

No field must be left empty login

No field must be left empty motdepasse

No field must be left empty bdd

Authentication error (invalid login / password)

This database does not appear to belong to you

A SQL error occurred

Example with NuSOAP

include('nusoap/nusoap.php');

$client = new soapclient('https://www.eml-srv.com/_soap/control.php'); // Remove the 's' from 'https' if CURL is not installed

$parametres = array( 'login'=>'your_login', 'motdepasse'=>'your_password', 'bdd'=>'21', 'champ'=>'Email', 'recherche'=>'email@domain.com' );

$variable=$client->call('Recherche_BDD', $parametres);

// Retrieve the error, if any
if($client->fault)
die("Error:Code: {$client->faultcode}"
. "Detail: {$client->faultactor}"
. "Solution: {$client->faultstring}");

print_r($variable);

Which gives a result like:

Array
(
    [0] => Array
        (
            [__numeric_0] => 169
            [pkey_id] => 169
            [__numeric_1] => email@domain.com
            [Email] => email@domain.com
            [__numeric_2] => The company
            [Societe] => The company
            [__numeric_3] => The address
            [Adresse] => The address
            [__numeric_4] => The postal code
            [Code_postal] => The postal code
            [__numeric_5] => The city
            [Ville] => The city
            [__numeric_6] => The phone
            [Telephone] => The phone
            [__numeric_7] => The fax
            [Fax] => The fax
            [__numeric_8] => The website
            [Site_web] => The website
        )

    [1] => Array
        (
            [__numeric_0] => 168
            [pkey_id] => 168
            [__numeric_1] => email@domain.com
            [Email] => email@domain.com
            [__numeric_2] => The company
            [Societe] => The company
            [__numeric_3] => The address
            [Adresse] => The address
            [__numeric_4] => The postal code
            [Code_postal] => The postal code
            [__numeric_5] => The city
            [Ville] => The city
            [__numeric_6] => The phone
            [Telephone] => The phone
            [__numeric_7] => The fax
            [Fax] => The fax
            [__numeric_8] => The website
            [Site_web] => The website
        )

)

Example with PHP5

try { $client = new SoapClient(null, array('location' => "https://www.eml-srv.com/_soap/control.php", 'uri'      => "https://www.eml-srv.com", 'encoding'=>'ISO-8859-1'  ));

$variable = $client->Recherche_BDD('your_login','your_password','21','Email','email@domain.com'); //or //$variable = $client->__soapCall(Recherche_BDD,$parametres);

print_r($variable); } catch (SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);

}
Last updated on