Database


Database Instance

Simple Database Implementation.

MySQL Instance

Implementation MySQL instance.

$config = [
    "host" => "localhost",
    "username" => "root",
    "password" => "",
    "database" => "database",
    "port" => 3306
];

$database = new \Samy\Database\MySql($config);

PostgreSQL Instance

Implementation PostgreSQL instance.

$config = [
    "host" => "localhost",
    "username" => "postgres",
    "password" => "postgres",
    "database" => "database",
    "port" => 5432
];

$database = new \Samy\Database\PostgreSql($config);

Database Configuration

MySQL Configuration

NameTypeDefaultDescription
hoststringlocalhostCan be either a host name or an IP address.
usernamestringrootThe MySQL user name.
passwordstringThe MySQL password.
databasestringThe MySQL database to be used when performing queries.
portint3306The MySQL port number to be used to connect.

PostgreSQL Configuration

NameTypeDefaultDescription
hoststringlocalhostCan be either a host name or an IP address.
usernamestringpostgresThe PostgreSQL user name.
passwordstringpostgresThe PostgreSQL password.
databasestringThe PostgreSQL database to be used when performing queries.
portint5432The PostgreSQL port number to be used to connect.

Database Constants

Field Type

NameValue
DatabaseFieldType::UNKNOWN0
DatabaseFieldType::BOOLEAN1
DatabaseFieldType::INTEGER2
DatabaseFieldType::FLOAT3
DatabaseFieldType::STRING4
DatabaseFieldType::TIME5

Condition

NameValue
DatabaseCondition::ANDAND
DatabaseCondition::OROR

Order

NameValue
DatabaseOrder::ASCASC
DatabaseOrder::DESCDESC