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


$databaseManager = new \krzysztofzylka\DatabaseManager\DatabaseManager();

try {
    $connect = \krzysztofzylka\DatabaseManager\DatabaseConnect::create()
        ->setType(\krzysztofzylka\DatabaseManager\Enum\DatabaseType::mysql)
        ->setDatabaseName('database')
        ->setUsername('username')
        ->setPassword('password');
    
    $databaseManager->connect($connect);
} catch (\krzysztofzylka\DatabaseManager\Exception\DatabaseManagerException $exception) {
    die($exception->getHiddenMessage());
}

$table = new \krzysztofzylka\DatabaseManager\Table('table name')

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
var_dump($table->query('sql'));

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
var_dump(
    $table->find()
);

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
var_dump(
    $table->findAll()
);

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
var_dump(
    $table->findCount()
);

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
var_dump(
    $table->findIsset()
);

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
$table->insert([
    'column' => 'value'
])

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
$table->setId('element id')->update([
    'column' => 'new value'
])

$table = new \krzysztofzylka\DatabaseManager\Table('table name');
$table->setId('element id')->updateValue('column', 'new value');

$conditions = [
    'column' => 'value',
    'column2' => 'value'
];

$conditions = [
    'column' => 'value',
    new \krzysztofzylka\DatabaseManager\Condition('column', '>', 5),
    new \krzysztofzylka\DatabaseManager\Condition('column', 'LIKE', '%value%')
];