{"id":27185958,"url":"https://github.com/bdusell/jitsu-sqldb","last_synced_at":"2026-04-20T03:02:00.528Z","repository":{"id":56999491,"uuid":"42760873","full_name":"bdusell/jitsu-sqldb","owner":"bdusell","description":"Convenient object-oriented interface to SQL databases in PHP","archived":false,"fork":false,"pushed_at":"2016-05-07T08:39:04.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-25T17:49:52.504Z","etag":null,"topics":["database","mysql","php","sql","sql-database","sqlite","web-development"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdusell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-19T05:21:43.000Z","updated_at":"2017-10-17T21:14:36.000Z","dependencies_parsed_at":"2022-08-21T13:20:47.316Z","dependency_job_id":null,"html_url":"https://github.com/bdusell/jitsu-sqldb","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/bdusell/jitsu-sqldb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-sqldb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-sqldb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-sqldb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-sqldb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdusell","download_url":"https://codeload.github.com/bdusell/jitsu-sqldb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdusell%2Fjitsu-sqldb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32031070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","mysql","php","sql","sql-database","sqlite","web-development"],"created_at":"2025-04-09T17:55:39.044Z","updated_at":"2026-04-20T03:02:00.520Z","avatar_url":"https://github.com/bdusell.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"jitsu/sqldb\n-----------\n\nThis package defines a convenient object-oriented interface to SQL databases\nand SQL statements, built on top of PHP's PDO library. While PDO already\nprovides a unified, object-oriented API supporting multiple SQL drivers, this\nlibrary offers an API which is easier to use, adding some extra helper methods\nand providing better error handling. It makes parameter binding less painful in\nparticular.\n\nThis package is part of [Jitsu](https://github.com/bdusell/jitsu).\n\n## Installation\n\nInstall this package with [Composer](https://getcomposer.org/):\n\n```sh\ncomposer require jitsu/sqldb\n```\n\n## Namespace\n\nAll classes are defined under the namespace `Jitsu`. The database-related\nclasses are defined under `Jitsu\\Sql`.\n\n## Usage\n\nHere's an example:\n\n```php\n\u003c?php\nuse Jitsu\\Sql\\Database;\nuse Jitsu\\Sql\\MysqlDatabase;\n\n$search_term = $_GET['query'];\n\n// Connect to the database\n$db = new MysqlDatabase('localhost', 'my_database',\n                        'my_user', 'my_password');\n// Run a query with named parameters\n$stmt = $db-\u003equery(\u003c\u003c\u003cSQL\n  select `name`, `description`\n  from `packages`\n  where `description` like :pattern\n  order by `description` = :term desc\nSQL\n  , [\n    'pattern' =\u003e '%' . Database::escapeLike($search_term) . '%',\n    'term' =\u003e $search_term\n  ]);\n\n// Iterate over results\nforeach($stmt as $row) {\n  echo $row-\u003ename, ': ', $row-\u003edescription, \"\\n\";\n}\n\n$user_id = $_SESSION['user_id'];\n\n// Get a single record using a positional parameter\n$user = $db-\u003erow(\u003c\u003c\u003cSQL\n  select `first_name`\n  from `users`\n  where `id` = ?\nSQL\n  , $user_id);\necho \"Welcome back, \", $user-\u003efirst_name, \"\\n\";\n\n// Get the first column of the first row\n$exists = $db-\u003eevaluate(\u003c\u003c\u003cSQL\n  select exists(\n    select 1\n    from `bookmarks`\n    join `packages` on `bookmarks`.`package_id` = `packages`.`id`\n    where `bookmarks`.`user_id` = ?\n    and `packages`.`name` = ?\n  )\nSQL\n  , $user_id, $search_term);\nif($exists) {\n  echo \"You have already bookmarked this package.\\n\"\n} else {\n  echo \"You have not bookmarked this package.\\n\";\n}\n```\n\nThis package also defines a database plugin for the\n[jitsu/app](https://github.com/bdusell/jitsu-app) package.\nIncluding the trait `\\Jitsu\\App\\Databases` in your application class adds a\n`database` method which can be used to configure a database connection for\nyour application to use. The request handler which this `database` method\nregisters adds a database connection object to the request `$data` object. This\ndatabase object comes with a twist \u0026ndash; it is lazily loaded, meaning that\nthe database connection will not be established until one of the object's\nmethods is used. This makes it easy to configure a database connection for\nmultiple request handlers in your application to use, but to avoid making that\nconnection when your application routes to a handler which does not need the\ndatabase at all (such as a page-not-found handler).\n\nThe `database` method accepts two arguments: the name of the property on the\nrequest `$data` object which the connection object will be assigned to, and the\nconfiguration options, which are defined in an array. For the second argument,\nthe `database` method will accept either an array or the name of a property on\nthe `$data-\u003econfig` object. By default, this is the same as the first argument.\nThe first argument also defaults to `'database'`.\n\nA quick example:\n\n```php\n\u003c?php\nclass MyApp extends \\Jitsu\\App\\Application {\n  use \\Jitsu\\App\\Databases;\n  public function initialize() {\n    $this-\u003edatabase('database', [\n      'driver'     =\u003e 'mysql',\n      'host'       =\u003e 'localhost',\n      'database'   =\u003e 'my_database',\n      'user'       =\u003e 'my_user',\n      'password'   =\u003e 'shhhhhhh',\n      'persistent' =\u003e true\n    ]);\n    $this-\u003eget('count-users', function($data) {\n      $count = $data-\u003edatabase-\u003eevaluate('select count(*) from `users`');\n      echo \"There are $count users. Honestly, that's $count more than I expected.\\n\";\n    });\n    $this-\u003enotFound(function($data) {\n      $data-\u003eresponse-\u003esetStatusCode(404, 'Not Found');\n      echo \"Nothing to see here. No database connection made.\\n\";\n    });\n  }\n}\n```\n\n## API\n\n### class Jitsu\\\\Sql\\\\Database\n\nAn object-oriented interface to a SQL database.\n\nThis is essentially a useful wrapper around the PDO library.\n\n#### new Database($driver\\_str, $username = null, $password = null, $options = array())\n\nConnect to a database upon construction.\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$driver_str`** | `string` | A PDO driver string. |\n| **`$username`** | `string|null` | An optional username. |\n| **`$password`** | `string|null` | An optional password. |\n| **`$options`** | `array` | An optional array of PDO options. |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |  |\n\n#### $database-\u003equery($query, $args,...)\n\nExecute a SQL query.\n\nExecutes a one-shot query and returns the resulting rows in an\niterable `Statement` object. The remaining parameters may be used to\npass arguments to the query. If there is only a single array passed\nas an additional argument, its contents are used as the parameters.\n\nFor example,\n\n    $stmt = $db-\u003equery($sql_code);\n    $stmt = $db-\u003equery($sql_code, $arg1, $arg2, ...);\n    $stmt = $db-\u003equery($sql_code, $arg_array);\n    foreach($stmt as $row) { $row-\u003ecolumn_name ... }\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$query`** | `string` | The SQL query. |\n| **`$args,...`** | `mixed` | Arguments to be interpolated into the query. If a single array is passed, its contents are used as the arguments. |\n| returns | `\\Jitsu\\Sql\\Statement` |  |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |  |\n\n#### $database-\u003equeryWith($query, $args)\n\nSame as `query`, but arguments are always passed in a single `$args`\narray.\n\n|   | Type |\n|---|------|\n| **`$query`** | `string` |\n| **`$args`** | `array` |\n| returns | `\\Jitsu\\Sql\\Statement` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003erow($query, $args,...)\n\nReturn the first row of a query and ignore the rest.\n\n|   | Type |\n|---|------|\n| **`$query`** | `string` |\n| **`$args,...`** | `mixed` |\n| returns | `\\Jitsu\\Sql\\Statement` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003erowWith($query, $args)\n\nLike `row`, but arguments are always passed in an array.\n\n|   | Type |\n|---|------|\n| **`$query`** | `string` |\n| **`$args`** | `array` |\n| returns | `\\Jitsu\\Sql\\Statement` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003eevaluate($query, $args,...)\n\nReturn the first column of the first row and ignore everything\nelse.\n\n|   | Type |\n|---|------|\n| **`$query`** | `string` |\n| **`$args,...`** | `mixed` |\n| returns | `\\Jitsu\\Sql\\Statement` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003eevaluateWith($query, $args)\n\nLike `evaluate`, but arguments are always passed in an array.\n\n|   | Type |\n|---|------|\n| **`$query`** | `string` |\n| **`$args`** | `array` |\n| returns | `\\Jitsu\\Sql\\Statement` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003eexecute()\n\nExecute a SQL statement.\n\nIf called with arguments, returns a `Statement`. Note that the\nnumber of affected rows is available via\n`Statement-\u003eaffectedRows()`. If called with no arguments,\nreturns a `StatementStub` object instead, which provides only the\n`affectedRows()` method.\n\n|   | Type |\n|---|------|\n| **`$query`** | `string` |\n| **`$arg,...`** | `mixed` |\n| returns | `\\Jitsu\\Sql\\QueryResultInterface` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003eexecuteWith($statement, $args)\n\nLike `execute`, but arguments are always passed in an array.\n\n|   | Type |\n|---|------|\n| **`$query`** | `string` |\n| **`$args`** | `array` |\n| returns | `\\Jitsu\\Sql\\QueryResultInterface` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003eprepare($statement)\n\nPrepare a SQL statement and return it as a `Statement`.\n\n|   | Type |\n|---|------|\n| **`$statement`** | `string` |\n| returns | `\\Jitsu\\Sql\\Statement` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003equote($s)\n\nEscape and quote a string value for interpolation in a SQL query.\n\nNote that the result *includes* quotes added around the string.\n\n|   | Type |\n|---|------|\n| **`$s`** | `string` |\n| returns | `string` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### Database::escapeLike($s, $esc = '\\\\\\\\')\n\nEscape characters in a string that have special meaning in SQL\n\"like\" patterns. Note that this should be coupled with an `ESCAPE`\nclause in the SQL; for example,\n\n    \"column\" LIKE '%foo\\%bar%' ESCAPE '\\'\n\nA `\\` is the default escape character.\n\n|   | Type |\n|---|------|\n| **`$s`** | `string` |\n| **`$esc`** | `string` |\n| returns | `string` |\n\n#### $database-\u003elastInsertId()\n\nGet the ID of the last inserted record.\n\n*Note that the result is always a string.*\n\n|   | Type | Description |\n|---|------|-------------|\n| returns | `string` | A string, which you will most likely want to cast to an integer. |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |  |\n\n#### $database-\u003ebegin()\n\nBegin a transaction.\n\nNote that uncommitted transactions are automatically rolled back\nwhen the script terminates.\n\n|   | Type |\n|---|------|\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003einTransaction()\n\nDetermine whether a transaction is active.\n\n|   | Type |\n|---|------|\n| returns | `bool` |\n\n#### $database-\u003erollback()\n\nRoll back the current transaction.\n\n|   | Type |\n|---|------|\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003ecommit()\n\nCommit the current transaction.\n\n|   | Type |\n|---|------|\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003etransaction($callback)\n\nRun a callback safely in a transaction.\n\nIf the callback throws an exception, the transaction will be rolled\nback, and the exception will be re-thrown.\n\n|   | Type |\n|---|------|\n| **`$callback`** | `callable` |\n| throws | `\\Exception` |\n\n#### $database-\u003eattribute($name)\n\nGet a database connection attribute.\n\nThe name passed should be a string (case-insensitive) and\ncorrespond to a PDO constant with the `PDO::ATTR_` prefix\ndropped.\n\nPossible names are:\n\n* `autocommit`\n* `case`\n* `client_version`\n* `connection_status`\n* `driver_name`\n* `errmode`\n* `oracle_nulls`\n* `persistent`\n* `prefetch`\n* `server_info`\n* `server_version`\n* `timeout`\n\n|   | Type |\n|---|------|\n| **`$name`** | `string` |\n| returns | `mixed` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003esetAttribute($name, $value)\n\nSet a database connection attribute.\n\nUses the same attribute name convention as `attribute`. The value\nshould be a string (case-insensitive) corresponding to a PDO\nconstant with the `PDO::ATTR_` prefix dropped.\n\n|   | Type |\n|---|------|\n| **`$name`** | `string` |\n| **`$value`** | `mixed` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### $database-\u003eattributes()\n\nGenerate a mapping of all attribute names and values.\n\n|   | Type |\n|---|------|\n| returns | `array` |\n| throws | `\\Jitsu\\Sql\\DatabaseException` |\n\n#### Database::drivers()\n\nGet a list of the available database drivers.\n\n|   | Type |\n|---|------|\n| returns | `string[]` |\n\n#### $database-\u003econnection()\n\nGet the underlying PDO connection object.\n\n|   | Type |\n|---|------|\n| returns | `\\PDO` |\n\n#### $database-\u003esetFetchMode($mode)\n\nSet the fetch mode.\n\nThe fetch mode determines the form in which rows are fetched. Use\nthe `PDO::FETCH_` constants directly. The default, `PDO::FETCH_OBJ`,\ncauses rows to be returned as `stdClass` objects with property\nnames corresponding to column names.\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$mode`** | `mixed` | A `PDO::FETCH_` constant. |\n\n#### $database-\u003efetchMode($mode)\n\nGet the fetch mode.\n\n|   | Type |\n|---|------|\n| returns | `mixed` |\n\n### class Jitsu\\\\Sql\\\\MysqlDatabase\n\nExtends `Database`.\n\nSpecialization of `Database` for MySQL.\n\n#### new MysqlDatabase($host, $database, $username, $password, $charset = 'utf8mb4', $options = null)\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$host`** | `string` | Host name. |\n| **`$database`** | `string` | Database name. |\n| **`$username`** | `string` | Username. |\n| **`$password`** | `string` | Password. |\n| **`$charset`** | `string` | Character set used by the connection. The default is `utf8mb4`, which supports all Unicode characters encoded in UTF-8. |\n| **`$options`** | `array|null` | Extra PDO options. |\n\n### class Jitsu\\\\Sql\\\\SqliteDatabase\n\nExtends `Database`.\n\nSpecialization of `Database` for SQLite.\n\n#### new SqliteDatabase($filename, $options = null)\n\nConnect to a SQLite database.\n\nNote that this always enables foreign key constraints. If for some\nstrange reason you actually want to turn this off, you can run\n\n    $db = new SqliteDatabase('foo.db');\n    $db-\u003eexecute('pragma foreign_keys = off');\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$filename`** | `string` | Name of the database file. |\n| **`$options`** | `array|null` | Extra PDO options. |\n\n### class Jitsu\\\\Sql\\\\Statement\n\nAn object-oriented interface to a prepared or executed SQL statement.\n\nThis is a convenient wrapper around the PDO statement class.\n\n#### new Statement($stmt, $mode = \\\\PDO::FETCH\\_OBJ)\n\nConstruct a SQL statement object.\n\nOptionally specify a fetch mode, which determines the form in which\nrows are fetched. Use the `PDO::FETCH_` constants directly. The\ndefault is `PDO::FETCH_OBJ`, which causes rows to be returned as\n`stdClass` objects with property names corresponding to column\nnames.\n\n|   | Type |\n|---|------|\n| **`$stmt`** | `\\PDOStatement` |\n| **`$mode`** | `mixed` |\n\n#### $statement-\u003ebindOutput($col, \u0026$var, $type = null, $inout = false)\n\nBind a result column to a variable.\n\nThe column can be 1-indexed or referenced by name.\n\n    $stmt = $db-\u003eprepare('select id, name from users');\n    $stmt-\u003ebind_output('name', $name);\n    foreach($stmt as $row) echo $name, \"\\n\";\n\nA type may optionally be specified. The following values may be\npassed as strings:\n\n* `bool`\n* `null`\n* `int`\n* `str`\n* `lob` (large object)\n\nThe `$inout` parameter specifies whether the column is an\n`INOUT` parameter for a stored procedure.\n\n|   | Type |\n|---|------|\n| **`$col`** | `int|string` |\n| **`$var`** | `mixed` |\n| **`$type`** | `string|null` |\n| **`$inout`** | `bool` |\n\n#### $statement-\u003ebindInput($param, \u0026$var, $type = null, $inout = false)\n\nBind an input parameter of a prepared statement to a variable.\n\nThe parameter can be 1-indexed or referenced by name (include the\ncolon).\n\nExample 1:\n\n    $stmt = $db-\u003eprepare('select id, name from users where phone = ?');\n    $stmt-\u003ebind_input(1, $phone);\n    $phone = '5551234567';\n    $stmt-\u003eexecute();\n\nExample 2:\n\n    $stmt = $db-\u003eprepare('select id, name from users where phone = :phone');\n    $stmt-\u003ebind_input(':phone', $phone);\n\n|   | Type |\n|---|------|\n| **`$param`** | `int|string` |\n| **`$var`** | `mixed` |\n| **`$type`** | `string|null` |\n| **`$inout`** | `bool` |\n\n#### $statement-\u003eassignInput($param, $value, $type = null, $inout = false)\n\nAssign a value to an input parameter of a prepared statement.\n\nIf `$type` is null, the appropriate type is used based on the PHP\ntype of the value.\n\n|   | Type |\n|---|------|\n| **`$param`** | `int|string` |\n| **`$value`** | `mixed` |\n| **`$type`** | `string|null` |\n| **`$type`** | `bool` |\n\n#### $statement-\u003eassign($values,...)\n\nAssign an array of values to the inputs of a prepared statement.\n\nFor named parameters, pass an array mapping names (no colons) to\nvalues. For positional parameters, pass a sequential array\n(0-indexed). A positional parameter array may be passed as a single\narray argument or as a variadic argument list.\n\n    $stmt = $db-\u003eprepare('select * from users where first = ? and last = ?');\n    $stmt-\u003eassign('John', 'Doe');\n\n|   | Type |\n|---|------|\n| **`$values,...`** | `mixed` |\n\n#### $statement-\u003eassignWith($values)\n\nLike `assign`, but arguments are always passed in an array.\n\n|   | Type |\n|---|------|\n| **`$values`** | `array` |\n\n#### $statement-\u003eexecute($values = null)\n\nExecute this statement, optionally providing a 0-indexed array of\nvalues.\n\nThe values array may be convenient in simple cases, but it only\nworks for positional parameters and casts all values to the SQL\nstring type (`'str'`). A more flexible alternative is to call\n`assign` beforehand.\n\n|   | Type |\n|---|------|\n| **`$values`** | `array|null` |\n\n#### $statement-\u003eevaluate($values = null)\n\nEquivalent to running `$this-\u003eexecute()` and returning\n`$this-\u003evalue()`.\n\n|   | Type |\n|---|------|\n| **`$values`** | `array|null` |\n| returns | `mixed` |\n\n#### $statement-\u003eclose()\n\nIgnore the rest of the records returned by this statement so as to\nmake it executable again.\n\n#### $statement-\u003efirst()\n\nReturn the first row and ignore the rest.\n\nIf there are no records returned, return `null`.\n\nNote that this won't work with some fetch modes.\n\n|   | Type |\n|---|------|\n| returns | `mixed` |\n\n#### $statement-\u003evalue()\n\nReturn the first cell of the first row and ignore anything else.\n\nIf no records are returned, return `null`.\n\n|   | Type |\n|---|------|\n| returns | `mixed` |\n\n#### $statement-\u003ecolumnCount()\n\nReturn the number of columns in the result set, or 0 if there is no\nresult set.\n\n|   | Type |\n|---|------|\n| returns | `int` |\n\n#### $statement-\u003eaffectedRows()\n\nReturn the number of rows affected by the last execution of this\nstatement.\n\n|   | Type |\n|---|------|\n| returns | `int` |\n\n#### $statement-\u003etoArray()\n\nReturn all of the rows copied into an array.\n\n|   | Type |\n|---|------|\n| returns | `mixed[]` |\n\n#### $statement-\u003emap($callback)\n\nReturn all of the rows passed through a function and copied into an\narray.\n\nThe columns of each row are passed as positional parameters to the\nfunction.\n\n|   | Type |\n|---|------|\n| **`$callback`** | `callable` |\n| returns | `mixed[]` |\n\n#### $statement-\u003enextRowset()\n\nAdvance to the next set of rows returned by the query, which is\nsupported by some stored procedures.\n\n#### $statement-\u003ecurrent()\n\n#### $statement-\u003ekey()\n\n#### $statement-\u003enext()\n\n#### $statement-\u003erewind()\n\n#### $statement-\u003evalid()\n\n#### $statement-\u003edebug()\n\nPrint debugging information to *stdout*.\n\n|   | Type |\n|---|------|\n| returns | `$this` |\n\n### class Jitsu\\\\Sql\\\\StatementStub\n\nImplements `QueryResultInterface`.\n\nA query result consisting only of the number of affected rows.\n\n#### new StatementStub($affected\\_rows)\n\n#### $statement\\_stub-\u003eaffectedRows()\n\n### interface Jitsu\\\\Sql\\\\QueryResultInterface\n\n#### $query\\_result\\_interface-\u003eaffectedRows()\n\nThe number of rows affected by the SQL statement.\n\n|   | Type |\n|---|------|\n| returns | `int` |\n\n### class Jitsu\\\\Sql\\\\DatabaseException\n\nAn exception class for database-related errors.\n\n#### new DatabaseException($msg, $errstr, $code = null, $state = null, $sql = null)\n\nConstruct a database exception object.\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$msg`** | `string` | A descriptive error message. |\n| **`$errstr`** | `string` | The error string returned by the database driver/library. |\n| **`$code`** | `int|null` | Optional error code. |\n| **`$state`** | `int|null` | Optional SQL state after the error. |\n| **`$sql`** | `string|null` | Optional SQL code which caused the error. |\n\n#### $database\\_exception-\u003egetSqlErrorCode()\n\nGet the SQL engine's error code.\n\n|   | Type |\n|---|------|\n| returns | `int|null` |\n\n#### $database\\_exception-\u003egetSqlState()\n\nGet the SQL state abbreviation.\n\n|   | Type |\n|---|------|\n| returns | `string|null` |\n\n#### $database\\_exception-\u003egetErrorString()\n\nGet the error string reported by the database driver.\n\n|   | Type |\n|---|------|\n| returns | `string|null` |\n\n#### $database\\_exception-\u003egetSql()\n\nGet the SQL code which caused the error.\n\n|   | Type |\n|---|------|\n| returns | `string|null` |\n\n#### $database\\_exception-\u003e\\_\\_toString()\n\nReturn a suitable string representation of the database error.\n\n|   | Type |\n|---|------|\n| returns | `string` |\n\n### trait Jitsu\\\\App\\\\Databases\n\nMixin for `Jitsu\\App\\Application` which adds configurable database\nconnection functionality.\n\n#### $databases-\u003edatabase($data\\_prop = 'database', $config = null)\n\nThe configuration settings should be defined in an array. The\nfollowing keys are recognized:\n\n* `driver`: The name of the SQL software used by the database.\n  Either `'sqlite'` or `'mysql'`. Mandatory.\n* `persistent`: Whether to use persistent database connections.\n  Default is `false`.\n* `host`: (MySQL) The name of the host hosting the database.\n* `database`: (MySQL) The name of the MySQL database.\n* `user`: (MySQL) The name of the MySQL user used to log in.\n* `password`: (MySQL) The password used to log in.\n* `charset`: (MySQL) The character set used by the connection.\n  Default is `'utf8mb4'`, which supports all Unicode characters\n  encoded in UTF-8.\n* `file`: (SQLite) The name of the database file.\n\n|   | Type | Description |\n|---|------|-------------|\n| **`$data_prop`** | `string` | Name of the property on `$data` where the database connection object will be assigned. By default, it is assigned to `$data-\u003edatabase`. |\n| **`$config`** | `array|string|null` | Configuration settings for the database connection. Either an array or the name of a property on `$data-\u003econfig`. By default, this is set to the same string as `$data_prop`. |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fjitsu-sqldb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdusell%2Fjitsu-sqldb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdusell%2Fjitsu-sqldb/lists"}