Skip to content

Database connection

AngelNovo edited this page Aug 10, 2024 · 5 revisions

Types of database connections

  • PDO
    • Mysql

Required data

The enviroment variables for the mysql_database must be set
just like the example

Mysql PDO example

use lib\connection\Mysql
$db = new Connection();
$sql = $db->newQuery('show tables');
/* Data will contain a dataset with the query result */
$data = $sql->Execute();
// Do not forget to close the connection
$sql->close();

Parameters

$sql = $db->newQuery('select * from table_name where id = :id');
$sql->params->id = 23
Clone this wiki locally