`$ composer require "ibrahimozturkme/easydb":"dev-master"
$database
: String.$host
: String.$username
: String.$password
: String.$charset
: String.
Server Mode
$db = new \EasyDB\Connection('database_name', 'localhost', 'ibrahimozturk', '12341234', 'utf8');
Localhost mode
$db = new \EasyDB\Connection('database_name');
-
$proccess
: String. -
$table
: String.$db->sql('select', 'articles');
-
$fields
: String.$db->sql('select', 'articles')->from('id, title, article');
-
$array
: Array. Form data$db->sql('insert', 'articles')->serialize($_POST)->result();
-
$type
: String. -
$array
: Array. Form data$db->sql('update', 'articles')->serialize($array)->additional('WHERE id = :id', ['id' => 2])->result();
Query result.
$db->sql('select', 'articles')->result();
SELECT - Single
$query = $db->sql('select', 'articles')->additional('WHERE id = :id', ['id' => 2])->result();
echo $query->count;
echo $query->result->title;
SELECT - Multiple
$query = $db->sql('select', 'articles')->result();
echo $query->count;
foreach($query->result as $row){
echo $row->title.'<br>';
}
SELECT - From
$query = $db->sql('select', 'articles')->from('id, title, article')->result();
echo $query->count;
foreach($query->result as $row){
echo $row->title.'<br>';
}
INSERT
$insert = $db->sql('insert', 'articles')->serialize($array)->result();
echo $insert->last_id;
echo ($insert->result) ? 'Has been added.' : 'Could not be added.';
UPDATE
$update = $db->sql('update', 'articles')->serialize($array)->additional('WHERE id = :id', ['id' => 2])->result();
echo ($update->result) ? 'Have been updated.' : 'Update failed.';
DELETE
$delete = $db->sql('delete', 'articles')->additional('WHERE id = :id', ['id' => 2])->result();
echo ($update->result) ? 'Has been deleted.' : 'Could not be deleted.';