\client

An interface to the client table in the database

Summary

Methods
Properties
Constants
__construct()
getId()
getName()
setName()
getContactIds()
getContacts()
delete()
createContact()
No public properties found
No constants found
No protected methods found
$pdo
$id
$name
N/A
No private methods found
No private properties found
N/A

Properties

$pdo

$pdo : \pdo

Type

\pdo — The PDO class for database communication

$id

$id : \pdo

Type

\pdo — The PDO class for database communication

$name

$name : \pdo

Type

\pdo — The PDO class for database communication

Methods

__construct()

__construct(\PDO  $pdo, integer  $id) 

Create a new instance

Parameters

\PDO $pdo

The PDO class, to access the database

integer $id

The id of the client to fetch

Throws

\PDOException

If something went wrong with the database

\Exception

If the client could not be found

getId()

getId() : integer

Get the ID of the client

Returns

integer —

The ID

getName()

getName() : string

Get the name of the client

Returns

string —

The name

setName()

setName(string  $name) : boolean

Set the name of the client

Parameters

string $name

The new name for the client

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getContactIds()

getContactIds() : array<mixed,integer>

Get all contact ids for this client

Throws

\PDOException

Is something went wrong with the database

Returns

array<mixed,integer> —

The ids

getContacts()

getContacts() : array<mixed,\contact>

Get all contacts for this client

Throws

\PDOException

If something went wrong with the database

Returns

array<mixed,\contact> —

An array indexed by id of instances of the contact class

delete()

delete() : boolean

Remove this client from the database

If this doesn't succeed (i.e. false is returned), that means the client was removed manually or by another instance of this class

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on success, false on failure

createContact()

createContact(string  $name, string  $email, string  $address, string  $address_2, string  $postal_code, string  $city, string  $country) : \contact

Make a new contact for this client

Parameters

string $name

The name for this contact

string $email

The email for this contact

string $address

The first address line of this contact (normally street and house number)

string $address_2

The second address line of this contact

string $postal_code

The postal code for this contact

string $city

The city for this contact

string $country

The country for this contact

Throws

\PDOException

If something went wrong with the database

\Exception

If there was a problem with the input

Returns

\contact

A new instance of the contact class containing the new contact