-
Notifications
You must be signed in to change notification settings - Fork 0
Table
Krzysztof Żyłka edited this page Dec 30, 2022
·
7 revisions
$table = (new Table())->setName('table_name');
$table = (new Table())->setName('table_name');
$id = $table->getId(); //get id (insert)
$table->setId('int'); //set id (update)
See Condition
use \krzysztofzylka\DatabaseManager\Condition;
$table = (new Table())->setName('table_name');
$conditions = new Condition(); //conditions not required
$find = $table->find($conditions);
/**
* example find
* [
* 'table_name' => [
* 'id' => 1,
* 'name' => 'string'
* ]
* ]
*/
See Condition
use \krzysztofzylka\DatabaseManager\Condition;
$table = (new Table())->setName('table_name');
$conditions = new Condition(); //conditions not required
$find = $table->findAll($conditions);
/**
* example findAll
* [
* 0 => [
* 'table_name' => [
* 'id' => 1,
* 'name' => 'string'
* ]
* ]
* ]
*/
See Condition
use \krzysztofzylka\DatabaseManager\Condition;
$table = (new Table())->setName('table_name');
$condition = new Condition();
$count = $table->findCount($condition); // int, condition is not required
See Condition
use \krzysztofzylka\DatabaseManager\Condition;
$table = (new Table())->setName('table_name');
$condition = (new Condition())->where('login', 'admin'); //isset user in database
$isset = $table->findCount($condition); // bool, condition is not required
See Condition
$table = (new Table())->setName('table_name');
$table->insert([
'column1' => 'value1',
'column2' => 'value2'
]); //return true or false
$insertId = $table->getId(); //insert ID
$table = (new Table())->setName('table_name')->setId(1);
$table->update([
'column1' => 'updated column1',
'column2' => 'updated column2'
]); //return true or false
$table = (new Table())->setName('table_name')->setId(1);
$table->updateValue('column1', 'new value'); //return bool
$table = (new Table())->setName('table_name');
$table->setId(2)->delete(); // delete item id=2
$table->delete(6); //delete item id=6
$columnName = null; //get single column data, default null
$table = (new Table())->setName('table_name')->columnList($columnName);
Response value (for MySQL and SQLite): https://dev.mysql.com/doc/refman/8.0/en/show-columns.html
Compatible with v1.0.3