Skip to content

Commit

Permalink
readme.md: static -> object
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 9, 2018
1 parent 369f5ee commit 34b7e22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,34 @@ available on the [homepage](https://dibiphp.com).
Connect to database:

```php
// connect to database (static way)
dibi::connect([
'driver' => 'mysql',
$dibi = new Dibi\Connection([
'driver' => 'mysqli',
'host' => 'localhost',
'username' => 'root',
'password' => '***',
]);

// or object way; in all other examples use $connection-> instead of dibi::
$connection = new DibiConnection($options);

// or static way; in all other examples use dibi:: instead of $dibi->
dibi::connect($options);
```

SELECT, INSERT, UPDATE

```php
dibi::query('SELECT * FROM users WHERE id = ?', $id);
$dibi->query('SELECT * FROM users WHERE id = ?', $id);

$arr = [
'name' => 'John',
'is_admin' => true,
];
dibi::query('INSERT INTO users', $arr);
$dibi->query('INSERT INTO users', $arr);
// INSERT INTO users (`name`, `is_admin`) VALUES ('John', 1)

dibi::query('UPDATE users SET', $arr, 'WHERE `id`=?', $x);
$dibi->query('UPDATE users SET', $arr, 'WHERE `id`=?', $x);
// UPDATE users SET `name`='John', `is_admin`=1 WHERE `id` = 123

dibi::query('UPDATE users SET', [
$dibi->query('UPDATE users SET', [
'title' => array('SHA1(?)', 'tajneheslo'),
]);
// UPDATE users SET 'title' = SHA1('tajneheslo')
Expand All @@ -72,7 +72,7 @@ dibi::query('UPDATE users SET', [
Getting results

```php
$result = dibi::query('SELECT * FROM users');
$result = $dibi->query('SELECT * FROM users');

$value = $result->fetchSingle(); // single value
$all = $result->fetchAll(); // all rows
Expand All @@ -88,7 +88,7 @@ foreach ($result as $n => $row) {
Modifiers for arrays:

```php
dibi::query('SELECT * FROM users WHERE %and', [
$dibi->query('SELECT * FROM users WHERE %and', [
array('number > ?', 10),
array('number < ?', 100),
]);
Expand All @@ -111,7 +111,7 @@ dibi::query('SELECT * FROM users WHERE %and', [
Modifiers for LIKE

```php
dibi::query("SELECT * FROM table WHERE name LIKE %like~", $query);
$dibi->query("SELECT * FROM table WHERE name LIKE %like~", $query);
```

<table>
Expand All @@ -123,7 +123,7 @@ dibi::query("SELECT * FROM table WHERE name LIKE %like~", $query);
DateTime:

```php
dibi::query('UPDATE users SET', [
$dibi->query('UPDATE users SET', [
'time' => new DateTime,
]);
// UPDATE users SET ('2008-01-01 01:08:10')
Expand Down
2 changes: 1 addition & 1 deletion src/Dibi/dibi.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class dibi
/** @var string Default dibi driver */
public static $defaultDriver = 'mysqli';

/** @var Dibi\Connection[] Connection registry storage for DibiConnection objects */
/** @var Dibi\Connection[] Connection registry storage for Dibi\Connection objects */
private static $registry = [];

/** @var Dibi\Connection Current connection */
Expand Down

0 comments on commit 34b7e22

Please sign in to comment.