{"id":13609616,"url":"https://github.com/dg/dibi","last_synced_at":"2026-02-22T22:56:38.941Z","repository":{"id":636068,"uuid":"277297","full_name":"dg/dibi","owner":"dg","description":"Dibi - smart database abstraction layer","archived":false,"fork":false,"pushed_at":"2025-03-30T17:41:11.000Z","size":3392,"stargazers_count":494,"open_issues_count":34,"forks_count":139,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-05-11T02:07:54.334Z","etag":null,"topics":["database","dibi","mysql","pdo","php","postgresql","sqlite","sqlserver"],"latest_commit_sha":null,"homepage":"https://dibiphp.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","funding":".github/funding.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"dg"}},"created_at":"2009-08-13T20:17:06.000Z","updated_at":"2025-05-03T23:09:19.000Z","dependencies_parsed_at":"2023-07-05T15:02:55.189Z","dependency_job_id":"580d7123-4af4-49ba-93b9-4f4a6889ecf2","html_url":"https://github.com/dg/dibi","commit_stats":{"total_commits":1016,"total_committers":90,"mean_commits":11.28888888888889,"dds":"0.17421259842519687","last_synced_commit":"a0003f8b3dde24f8c204d0ca0919f5a21db8e982"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Fdibi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Fdibi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Fdibi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dg%2Fdibi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dg","download_url":"https://codeload.github.com/dg/dibi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253678878,"owners_count":21946316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","dibi","mysql","pdo","php","postgresql","sqlite","sqlserver"],"created_at":"2024-08-01T19:01:36.532Z","updated_at":"2026-02-22T22:56:38.935Z","avatar_url":"https://github.com/dg.png","language":"PHP","readme":"[Dibi](https://dibi.nette.org) - smart database layer for PHP  [![Buy me a coffee](https://files.nette.org/images/coffee1s.png)](https://nette.org/make-donation?to=dibi)\n=========================================================\n\n[![Downloads this Month](https://img.shields.io/packagist/dm/dibi/dibi.svg)](https://packagist.org/packages/dibi/dibi)\n[![Tests](https://github.com/dg/dibi/workflows/Tests/badge.svg?branch=master)](https://github.com/dg/dibi/actions)\n[![Build Status Windows](https://ci.appveyor.com/api/projects/status/github/dg/dibi?branch=master\u0026svg=true)](https://ci.appveyor.com/project/dg/dibi/branch/master)\n[![Latest Stable Version](https://poser.pugx.org/dibi/dibi/v/stable)](https://github.com/dg/dibi/releases)\n[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/dg/dibi/blob/master/license.md)\n\n\nIntroduction\n------------\n\nDatabase access functions in PHP are not standardised. This library\nhides the differences between them, and above all, it gives you a very handy interface.\n\n\nSupport Me\n----------\n\nDo you like Dibi? Are you looking forward to the new features?\n\n[![Buy me a coffee](https://files.nette.org/icons/donation-3.svg)](https://github.com/sponsors/dg)\n\nThank you!\n\n\nInstallation\n------------\n\nInstall Dibi via Composer:\n\n```bash\ncomposer require dibi/dibi\n```\n\nThe Dibi 6.0 requires PHP version 8.2 and supports PHP up to 8.5.\n\n\nUsage\n-----\n\nRefer to the `examples` directory for examples. Dibi documentation is\navailable on the [homepage](https://dibi.nette.org).\n\n\n### Connecting to database\n\nThe database connection is represented by the object `Dibi\\Connection`:\n\n```php\n$database = new Dibi\\Connection([\n\t'driver'   =\u003e 'mysqli',\n\t'host'     =\u003e 'localhost',\n\t'username' =\u003e 'root',\n\t'password' =\u003e '***',\n\t'database' =\u003e 'table',\n]);\n\n$result = $database-\u003equery('SELECT * FROM users');\n```\n\nAlternatively, you can use the `dibi` static register, which maintains a connection object in a globally available storage and calls all the functions above it:\n\n```php\ndibi::connect([\n\t'driver'   =\u003e 'mysqli',\n\t'host'     =\u003e 'localhost',\n\t'username' =\u003e 'root',\n\t'password' =\u003e '***',\n\t'database' =\u003e 'test',\n\t'charset'  =\u003e 'utf8',\n]);\n\n$result = dibi::query('SELECT * FROM users');\n```\n\nIn the event of a connection error, it throws `Dibi\\Exception`.\n\n\n\n### Queries\n\nWe query the database queries by the method `query()` which returns `Dibi\\Result`. Rows are objects `Dibi\\Row`.\n\nYou can try all the examples [online at the playground](https://repl.it/@DavidGrudl/dibi-playground).\n\n```php\n$result = $database-\u003equery('SELECT * FROM users');\n\nforeach ($result as $row) {\n\techo $row-\u003eid;\n\techo $row-\u003ename;\n}\n\n// array of all rows\n$all = $result-\u003efetchAll();\n\n// array of all rows, key is 'id'\n$all = $result-\u003efetchAssoc('id');\n\n// associative pairs id =\u003e name\n$pairs = $result-\u003efetchPairs('id', 'name');\n\n// the number of rows of the result, if known, or number of affected rows\n$count = $result-\u003egetRowCount();\n```\n\nMethod fetchAssoc() can return a more complex associative array.\n\nYou can easily add parameters to the query, note the question mark:\n\n```php\n$result = $database-\u003equery('SELECT * FROM users WHERE name = ? AND active = ?', $name, $active);\n\n// or\n$result = $database-\u003equery('SELECT * FROM users WHERE name = ?', $name, 'AND active = ?', $active););\n\n$ids = [10, 20, 30];\n$result = $database-\u003equery('SELECT * FROM users WHERE id IN (?)', $ids);\n```\n\n**WARNING: Never concatenate parameters to SQL. It would create a [SQL injection](https://en.wikipedia.org/wiki/SQL_injection)** vulnerability.\n```\n$result = $database-\u003equery('SELECT * FROM users WHERE id = ' . $id); // BAD!!!\n```\n\nInstead of a question mark, so-called modifiers can be used.\n\n```php\n$result = $database-\u003equery('SELECT * FROM users WHERE name = %s', $name);\n```\n\nIn case of failure `query()` throws `Dibi\\Exception`, or one of the descendants:\n\n- `ConstraintViolationException` - violation of a table constraint\n- `ForeignKeyConstraintViolationException` - invalid foreign key\n- `NotNullConstraintViolationException` - violation of the NOT NULL condition\n- `UniqueConstraintViolationException` - collides unique index\n\nYou can use also shortcuts:\n\n```php\n// returns associative pairs id =\u003e name, shortcut for query(...)-\u003efetchPairs()\n$pairs = $database-\u003efetchPairs('SELECT id, name FROM users');\n\n// returns array of all rows, shortcut for query(...)-\u003efetchAll()\n$rows = $database-\u003efetchAll('SELECT * FROM users');\n\n// returns row, shortcut for query(...)-\u003efetch()\n$row = $database-\u003efetch('SELECT * FROM users WHERE id = ?', $id);\n\n// returns field, shortcut for query(...)-\u003efetchSingle()\n$name = $database-\u003efetchSingle('SELECT name FROM users WHERE id = ?', $id);\n```\n\n\n### Modifiers\n\nIn addition to the `?` wildcard char, we can also use modifiers:\n\n| modifier | description\n|----------|-----\n| %s | string\n| %sN | string, but '' translates as NULL\n| %bin | binary data\n| %b | boolean\n| %i | integer\n| %iN | integer, but 0 is translates as NULL\n| %f | float\n| %d | date (accepts DateTime, string or UNIX timestamp)\n| %dt | datetime (accepts DateTime, string or UNIX timestamp)\n| %n | identifier, ie the name of the table or column\n| %N | identifier, treats period as a common character, ie alias or a database name (`%n AS %N` or `DROP DATABASE %N`)\n| %SQL | SQL - directly inserts into SQL (the alternative is Dibi\\Literal)\n| %ex | SQL expression or array of expressions\n| %lmt | special - adds LIMIT to the query\n| %ofs | special - adds OFFSET to the query\n\nExample:\n\n```php\n$result = $database-\u003equery('SELECT * FROM users WHERE name = %s', $name);\n```\n\nIf $name is null, the NULL is inserted into the SQL statement.\n\nIf the variable is an array, the modifier is applied to all of its elements and they are inserted into SQL separated by commas:\n\n```php\n$ids = [10, '20', 30];\n$result = $database-\u003equery('SELECT * FROM users WHERE id IN (%i)', $ids);\n// SELECT * FROM users WHERE id IN (10, 20, 30)\n```\n\nThe modifier `%n` is used if the table or column name is a variable. (Beware, do not allow the user to manipulate the content of such a variable):\n\n```php\n$table = 'blog.users';\n$column = 'name';\n$result = $database-\u003equery('SELECT * FROM %n WHERE %n = ?', $table, $column, $value);\n// SELECT * FROM `blog`.`users` WHERE `name` = 'Jim'\n```\n\nThree special modifiers are available for LIKE:\n\n| modifier | description\n|----------|-----\n| `%like~` | the expression starts with a string\n| `%~like` | the expression ends with a string\n| `%~like~` | the expression contains a string\n| `%like` | the expression matches a string\n\nSearch for names beginning with a string:\n\n```php\n$result = $database-\u003equery('SELECT * FROM table WHERE name LIKE %like~', $query);\n```\n\n\n### Modifiers for arrays\n\nThe parameter entered in the SQL query can also be an array. These modifiers determine how to compile the SQL statement:\n\n| modifier |   | result\n|----------|---|-----\n| %and   |        | `key1 = value1 AND key2 = value2 AND ...`\n| %or    |        | `key1 = value1 OR key2 = value2 OR ...`\n| %a     | assoc  | `key1 = value1, key2 = value2, ...`\n| %l %in | list   | `(val1, val2, ...)`\n| %v     | values | `(key1, key2, ...) VALUES (value1, value2, ...)`\n| %m     | multi  | `(key1, key2, ...) VALUES (value1, value2, ...), (value1, value2, ...), ...`\n| %by    | ordering | `key1 ASC, key2 DESC ...`\n| %n     | names  | `key1, key2 AS alias, ...`\n\nExample:\n\n```php\n$arr = [\n\t'a' =\u003e 'hello',\n\t'b'  =\u003e true,\n];\n\n$database-\u003equery('INSERT INTO table %v', $arr);\n// INSERT INTO `table` (`a`, `b`) VALUES ('hello', 1)\n\n$database-\u003equery('UPDATE `table` SET %a', $arr);\n// UPDATE `table` SET `a`='hello', `b`=1\n```\n\nIn the WHERE clause modifiers `%and` nebo `%or` can be used:\n\n```php\n$result = $database-\u003equery('SELECT * FROM users WHERE %and', [\n\t'name' =\u003e $name,\n\t'year' =\u003e $year,\n]);\n// SELECT * FROM users WHERE `name` = 'Jim' AND `year` = 1978\n```\n\nThe modifier `%by` is used to sort, the keys show the columns, and the boolean value will determine whether to sort in ascending order:\n\n```php\n$result = $database-\u003equery('SELECT id FROM author ORDER BY %by', [\n\t'id' =\u003e true, // ascending\n\t'name' =\u003e false, // descending\n]);\n// SELECT id FROM author ORDER BY `id`, `name` DESC\n```\n\n\n### Insert, Update \u0026 Delete\n\nWe insert the data into an SQL query as an associative array. Modifiers and wildcards `?` are not required in these cases.\n\n```php\n$database-\u003equery('INSERT INTO users', [\n\t'name' =\u003e $name,\n\t'year' =\u003e $year,\n]);\n// INSERT INTO users (`name`, `year`) VALUES ('Jim', 1978)\n\n$id = $database-\u003egetInsertId(); // returns the auto-increment of the inserted record\n\n$id = $database-\u003egetInsertId($sequence); // or sequence value\n```\n\nMultiple INSERT:\n\n```php\n$database-\u003equery('INSERT INTO users', [\n\t'name' =\u003e 'Jim',\n\t'year' =\u003e 1978,\n], [\n\t'name' =\u003e 'Jack',\n\t'year' =\u003e 1987,\n]);\n// INSERT INTO users (`name`, `year`) VALUES ('Jim', 1978), ('Jack', 1987)\n```\n\nDeleting:\n\n```php\n$database-\u003equery('DELETE FROM users WHERE id = ?', $id);\n\n// returns the number of deleted rows\n$affectedRows = $database-\u003egetAffectedRows();\n```\n\nUpdate:\n\n```php\n$database-\u003equery('UPDATE users SET', [\n\t'name' =\u003e $name,\n\t'year' =\u003e $year,\n], 'WHERE id = ?', $id);\n// UPDATE users SET `name` = 'Jim', `year` = 1978 WHERE id = 123\n\n// returns the number of updated rows\n$affectedRows = $database-\u003egetAffectedRows();\n```\n\nInsert an entry or update if it already exists:\n\n```php\n$database-\u003equery('INSERT INTO users', [\n\t'id' =\u003e $id,\n\t'name' =\u003e $name,\n\t'year' =\u003e $year,\n], 'ON DUPLICATE KEY UPDATE %a', [ // here the modifier %a must be used\n\t'name' =\u003e $name,\n\t'year' =\u003e $year,\n]);\n// INSERT INTO users (`id`, `name`, `year`) VALUES (123, 'Jim', 1978)\n//   ON DUPLICATE KEY UPDATE `name` = 'Jim', `year` = 1978\n```\n\n\n### Transaction\n\nThere are three methods for dealing with transactions:\n\n```php\n$database-\u003ebegin();\n\n$database-\u003ecommit();\n\n$database-\u003erollback();\n```\n\n\n### Testing\n\nIn order to play with Dibi a little, there is a `test()` method that you pass parameters like to `query()`, but instead of executing the SQL statement, it is echoed on the screen.\n\nThe query results can be echoed as a table using `$result-\u003edump()`.\n\nThese variables are also available:\n\n```php\ndibi::$sql; // the latest SQL query\ndibi::$elapsedTime; // its duration in sec\ndibi::$numOfQueries;\ndibi::$totalTime;\n```\n\n\n### Complex queries\n\nThe parameter may also be an object `DateTime`.\n\n```php\n$result = $database-\u003equery('SELECT * FROM users WHERE created \u003c ?', new DateTime);\n\n$database-\u003equery('INSERT INTO users', [\n\t'created' =\u003e new DateTime,\n]);\n```\n\nOr SQL literal:\n\n```php\n$database-\u003equery('UPDATE table SET', [\n\t'date' =\u003e $database-\u003eliteral('NOW()'),\n]);\n// UPDATE table SET `date` = NOW()\n```\n\nOr an expression in which you can use `?` or modifiers:\n\n```php\n$database-\u003equery('UPDATE `table` SET', [\n\t'title' =\u003e $database::expression('SHA1(?)', 'secret'),\n]);\n// UPDATE `table` SET `title` = SHA1('secret')\n```\n\nWhen updating, modifiers can be placed directly in the keys:\n\n```php\n$database-\u003equery('UPDATE table SET', [\n\t'date%SQL' =\u003e 'NOW()', // %SQL means SQL ;)\n]);\n// UPDATE table SET `date` = NOW()\n```\n\nIn conditions (ie, for `%and` and `%or` modifiers), it is not necessary to specify the keys:\n\n```php\n$result = $database-\u003equery('SELECT * FROM `table` WHERE %and', [\n\t'number \u003e 10',\n\t'number \u003c 100',\n]);\n// SELECT * FROM `table` WHERE (number \u003e 10) AND (number \u003c 100)\n```\n\nModifiers or wildcards can also be used in expressions:\n\n```php\n$result = $database-\u003equery('SELECT * FROM `table` WHERE %and', [\n\t['number \u003e ?', 10],  // or $database::expression('number \u003e ?', 10)\n\t['number \u003c ?', 100],\n\t['%or', [\n\t\t'left' =\u003e 1,\n\t\t'top' =\u003e 2,\n\t]],\n]);\n// SELECT * FROM `table` WHERE (number \u003e 10) AND (number \u003c 100) AND (`left` = 1 OR `top` = 2)\n```\n\nThe `%ex` modifier inserts all items of the array into SQL:\n\n```php\n$result = $database-\u003equery('SELECT * FROM `table` WHERE %ex', [\n\t$database::expression('left = ?', 1),\n\t'AND',\n\t'top IS NULL',\n]);\n// SELECT * FROM `table` WHERE left = 1 AND top IS NULL\n```\n\n\n### Conditions in the SQL\n\nConditional SQL commands are controlled by three modifiers `%if`, `%else`, and `%end`. The `%if` must be at the end of the string representing SQL and is followed by the variable:\n\n```php\n$user = ???\n\n$result = $database-\u003equery('\n\tSELECT *\n\tFROM table\n\t%if', isset($user), 'WHERE user=%s', $user, '%end\n\tORDER BY name\n');\n```\n\nThe condition can be supplemented by the section `%else`:\n\n```php\n$result = $database-\u003equery('\n\tSELECT *\n\tFROM %if', $cond, 'one_table %else second_table\n');\n```\n\nConditions can nest together.\n\n\n### Identifiers and strings in SQL\n\nSQL itself goes through processing to meet the conventions of the database. The identifiers (names of tables and columns) can be entered into square brackets or backticks, strings are quoted with single or double quotation marks, but the server always sends what the database asks for. Example:\n\n```php\n$database-\u003equery(\"UPDATE `table` SET [status]='I''m fine'\");\n// MySQL: UPDATE `table` SET `status`='I\\'m fine'\n// ODBC:  UPDATE [table] SET [status]='I''m fine'\n```\n\nThe quotation marks are duplicated inside the string in SQL.\n\n\n\n### Result as associative array\n\nExample: returns results as an associative field, where the key will be the value of the `id` field:\n\n```php\n$assoc = $result-\u003efetchAssoc('id');\n```\n\nThe greatest power of `fetchAssoc()` is reflected in a SQL query joining several tables with different types of joins. The database will make a flat table, fetchAssoc returns the shape.\n\nExample: Let's take a customer and order table (N:M binding) and query:\n\n```php\n$result = $database-\u003equery('\n  SELECT customer_id, customers.name, order_id, orders.number, ...\n  FROM customers\n  INNER JOIN orders USING (customer_id)\n  WHERE ...\n');\n```\n\nAnd we'd like to get a nested associative array by Customer ID and then Order ID:\n\n```php\n$all = $result-\u003efetchAssoc('customer_id|order_id');\n\n// we will iterate like this:\nforeach ($all as $customerId =\u003e $orders) {\n   foreach ($orders as $orderId =\u003e $order) {\n\t   ...\n   }\n}\n```\n\nAn associative descriptor has a similar syntax as when you type the array by assigning it to PHP. Thus `'customer_id|order_id'` represents the assignment series `$all[$customerId][$orderId] = $row;` sequentially for all rows.\n\nSometimes it would be useful to associate by the customer's name instead of his ID:\n\n```php\n$all = $result-\u003efetchAssoc('name|order_id');\n\n// the elements then proceeds like this:\n$order = $all['Arnold Rimmer'][$orderId];\n```\n\nBut what if there are more customers with the same name? The table should be in the form of:\n\n```php\n$row = $all['Arnold Rimmer'][0][$orderId];\n$row = $all['Arnold Rimmer'][1][$orderId];\n...\n```\n\nSo we can distinguish between multiple possible Rimmers using an array. The associative descriptor has a format similar to the assignment, with the sequence array representing `[]`:\n\n```php\n$all = $result-\u003efetchAssoc('name[]order_id');\n\n// we get all the Arnolds in the results\nforeach ($all['Arnold Rimmer'] as $arnoldOrders) {\n   foreach ($arnoldOrders as $orderId =\u003e $order) {\n\t   ...\n   }\n}\n```\n\nReturning to the example with the `customer_id|order_id` descriptor, we will try to list the orders of each customer:\n\n```php\n$all = $result-\u003efetchAssoc('customer_id|order_id');\n\nforeach ($all as $customerId =\u003e $orders) {\n   echo \"Customer $customerId\":\n\n   foreach ($orders as $orderId =\u003e $order) {\n\t   echo \"ID number: $order-\u003enumber\";\n\t   // customer name is in $order-\u003ename\n   }\n}\n```\n\nIt would be a nice to echo customer name too. But we would have to look for it in the `$orders` array. So let's adjust the results to such a shape:\n\n```php\n$all[$customerId]-\u003ename = 'John Doe';\n$all[$customerId]-\u003eorder_id[$orderId] = $row;\n$all[$customerId]-\u003eorder_id[$orderId2] = $row2;\n```\n\nSo, between `$clientId` and `$orderId`, we will also insert an intermediate item. This time not the numbered indexes as we used to distinguish between individual Rimmers, but a database row. The solution is very similar, just remember that the row symbolizes the arrow:\n\n```php\n$all = $result-\u003efetchAssoc('customer_id-\u003eorder_id');\n\nforeach ($all as $customerId =\u003e $row) {\n   echo \"Customer $row-\u003ename\":\n\n   foreach ($row-\u003eorder_id as $orderId =\u003e $order) {\n\t   echo \"ID number: $order-\u003enumber\";\n   }\n}\n```\n\n\n\n### Prefixes \u0026 substitutions\n\nTable and column names can contain variable parts. You will first define:\n\n```php\n// create new substitution :blog:  ==\u003e  wp_\n$database-\u003esubstitute('blog', 'wp_');\n```\n\nand then use it in SQL. Note that in SQL they are quoted by the colon:\n\n```php\n$database-\u003equery(\"UPDATE [:blog:items] SET [text]='Hello World'\");\n// UPDATE `wp_items` SET `text`='Hello World'\n```\n\n\n### Field data types\n\nDibi automatically detects the types of query columns and converts fields them to native PHP types. We can also specify the type manually. You can find the possible types in the `Dibi\\Type` class.\n\n```php\n$result-\u003esetType('id', Dibi\\Type::Integer); // id will be integer\n$row = $result-\u003efetch();\n\nis_int($row-\u003eid) // true\n```\n\n\n### Logger\n\nDibi has a built-in logger that lets you track all SQL statements executed and measure the length of their duration. Activating the logger:\n\n```php\n$database-\u003econnect([\n\t'driver'   =\u003e 'sqlite',\n\t'database' =\u003e 'sample.sdb',\n\t'profiler' =\u003e [\n\t\t'file' =\u003e 'file.log',\n\t],\n]);\n```\n\nA more versatile profiler is a Tracy panel that is activated when connected to Nette.\n\n\n\n### Connect to [Nette](https://nette.org)\n\nIn the configuration file, we will register the DI extensions and add the `dibi` section to create the required objects and also the database panel in the [Tracy](https://tracy.nette.org) debugger bar.\n\n```neon\nextensions:\n\tdibi: Dibi\\Bridges\\Nette\\DibiExtension3\n\ndibi:\n\thost: localhost\n\tusername: root\n\tpassword: ***\n\tdatabase: foo\n\tlazy: true\n```\n\nThen the object of connection can be [obtained as a service from the container DI](https://doc.nette.org/di-usage), eg:\n\n```php\nclass Model\n{\n\tprivate $database;\n\n\tpublic function __construct(Dibi\\Connection $database)\n\t{\n\t\t$this-\u003edatabase = $database;\n\t}\n}\n```\n","funding_links":["https://github.com/sponsors/dg"],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdg%2Fdibi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdg%2Fdibi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdg%2Fdibi/lists"}