PHP code example of krzysztofzylka / database-manager
1. Go to this page and download the library: Download krzysztofzylka/database-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
krzysztofzylka / database-manager example snippets
$table = new \krzysztofzylka\DatabaseManager\Table('users');
$table->delete(1); // Usunięcie po ID
// Usuwanie według warunków
$table->deleteByConditions(['status' => 'deleted']);
// Proste warunki z operatorami
$conditions = [
new \krzysztofzylka\DatabaseManager\Condition('age', '>', 18),
new \krzysztofzylka\DatabaseManager\Condition('status', 'IN', ['active', 'pending']),
'is_verified' => true
];
$results = $table->findAll($conditions);
$alterTable = new \krzysztofzylka\DatabaseManager\AlterTable('products');
// Dodawanie nowej kolumny
$column = new \krzysztofzylka\DatabaseManager\Column();
$column->setName('description')
->setType(\krzysztofzylka\DatabaseManager\Enum\ColumnType::text)
->setNull(true);
$alterTable->addColumn($column);
// Modyfikacja typu kolumny
$alterTable->modifyColumn('name', \krzysztofzylka\DatabaseManager\Enum\ColumnType::varchar, 100);
// Usunięcie kolumny
$alterTable->removeColumn('old_column');
$alterTable->execute();
// Zapisanie danych w cache
\krzysztofzylka\DatabaseManager\Cache::saveData('key', $value);
// Odczytanie danych z cache
$data = \krzysztofzylka\DatabaseManager\Cache::getData('key');