{"id":13660359,"url":"https://github.com/mikecao/sparrow","last_synced_at":"2025-04-06T03:08:21.801Z","repository":{"id":48983419,"uuid":"1602856","full_name":"mikecao/sparrow","owner":"mikecao","description":"A simple database toolkit for PHP","archived":false,"fork":false,"pushed_at":"2023-12-15T21:03:16.000Z","size":88,"stargazers_count":291,"open_issues_count":12,"forks_count":68,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-03-30T01:13:19.149Z","etag":null,"topics":["abstraction","database","library","orm","php","sql"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikecao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2011-04-12T06:50:33.000Z","updated_at":"2025-02-18T08:35:06.000Z","dependencies_parsed_at":"2024-08-02T05:18:07.580Z","dependency_job_id":null,"html_url":"https://github.com/mikecao/sparrow","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikecao%2Fsparrow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikecao%2Fsparrow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikecao%2Fsparrow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikecao%2Fsparrow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikecao","download_url":"https://codeload.github.com/mikecao/sparrow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"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":["abstraction","database","library","orm","php","sql"],"created_at":"2024-08-02T05:01:20.600Z","updated_at":"2025-04-06T03:08:21.760Z","avatar_url":"https://github.com/mikecao.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Sparrow\n\nSparrow is a simple but powerful database toolkit. Sparrow is a fluent SQL builder, database abstraction layer, cache manager,\nquery statistics generator, and micro-ORM all rolled into a single class file.\n\n## Requirements\n\nSparrow requires PHP 5.1 or greater.\n\n## Building SQL\n\n```php\n// Include the library\ninclude '/path/to/Sparrow.php';\n\n// Declare the class instance\n$db = new Sparrow;\n\n// Select a table\n$db-\u003efrom('user');\n\n// Build a select query\n$db-\u003eselect();\n\n// Display the SQL\necho $db-\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user\n```\n\n### Method Chaining\n\nSparrow allows you to chain methods together, so you can instead do:\n\n```php\necho $db-\u003efrom('user')-\u003eselect()-\u003esql();\n```\n\n### Where Conditions\n\nTo add where conditions to your query, use the `where` function.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id', 123)\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE id=123\n```\n\nYou can call where multiple times to add multiple conditions.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id', 123)\n  -\u003ewhere('name', 'bob')\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE id=123 AND name='bob'\n```\n\nYou can also pass an array to the where function. The following would produce the same output.\n\n```php\n$where = array('id' =\u003e 123, 'name' =\u003e 'bob');\n```\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere($where)\n  -\u003eselect()\n  -\u003esql();\n```\n\nYou can even pass in a string literal.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id = 99')\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE id = 99\n```\n\n### Custom Operators\n\nThe default operator for where queries is `=`. You can use different operators by placing\nthem after the field declaration.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id \u003e', 123)\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE id\u003e123;\n```\n\n### OR Queries\n\nBy default where conditions are joined together by `AND` keywords. To use OR instead, simply\nplace a `|` delimiter before the field name.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id \u003c', 10)\n  -\u003ewhere('|id \u003e', 20)\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE id\u003c10 OR id\u003e20\n```\n\n### LIKE Queries\n\nTo build a LIKE query you can use the special `%` operator.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('name %', '%bob%')\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE name LIKE '%bob%'\n```\n\nTo build a NOT LIKE query, add a `!` before the `%` operator.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('name !%', '%bob%')\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE name NOT LIKE '%bob%'\n```\n\n### IN Queries\n\nTo use an IN statement in your where condition, use the special `@` operator\nand pass in an array of values.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id @', array(10, 20, 30))\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE id IN (10,20,30)\n```\n\nTo build a NOT IN query, add a `!` before the `@` operator.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id !@', array(10, 20, 30))\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE id NOT IN (10,20,30)\n```\n\n### Selecting Fields\n\nTo select specific fields, pass an array in to the `select` function.\n\n```php\necho $db-\u003efrom('user')\n  -\u003eselect(array('id','name'))\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT id,name FROM user\n```\n\n### Limit and Offset\n\nTo add a limit or offset to a query, you can use the `limit` and `offset` functions.\n\n```php\necho $db-\u003efrom('user')\n  -\u003elimit(10)\n  -\u003eoffset(20)\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user LIMIT 10 OFFSET 20\n```\n\nYou can also pass in additional parameters to the `select` function.\n\n```php\necho $db-\u003efrom('user')\n  -\u003eselect('*', 50, 10)\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user LIMIT 50 OFFSET 10\n```\n\n### Distinct\n\nTo add a DISTINCT keyword to your query, call the `distinct` function.\n\n```php\necho $db-\u003efrom('user')\n  -\u003edistinct()\n  -\u003eselect('name')\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT DISTINCT name FROM user\n```\n\n### Table Joins\n\nTo add a table join, use the `join` function and pass in an array of fields to join on.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ejoin('role', array('role.id' =\u003e 'user.id'))\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user INNER JOIN role ON role.id=user.id\n```\n\nThe default join type is an `INNER` join. To build other types of joins you can use\nthe alternate join functions `leftJoin`, `rightJoin`, and `fullJoin`.\n\nThe join array works just like where conditions, so you can use custom operators and add multiple conditions.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ejoin('role', array('role.id' =\u003e 'user.id', 'role.id \u003e' =\u003e 10))\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user INNER JOIN role ON role.id=user.id AND role.id\u003e10\n```\n\n### Sorting\n\nTo add sorting to a query, use the `sortAsc` and `sortDesc` functions.\n\n```php\necho $db-\u003efrom('user')\n  -\u003esortDesc('id')\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user ORDER BY id DESC\n```\n\nYou can also pass an array to the sort functions.\n\n```php\necho $db-\u003efrom('user')\n  -\u003esortAsc(array('rank','name'))\n  -\u003eselect()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT * FROM user ORDER BY rank ASC, name ASC\n```\n\n### Grouping\n\nTo add a field to group by, use the `groupBy` function.\n\n```php\necho $db-\u003efrom('user')\n  -\u003egroupBy('points')\n  -\u003eselect(array('id','count(*)'))\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nSELECT id, count(*) FROM user GROUP BY points\n```\n\n### Insert Queries\n\nTo build an insert query, pass in an array of data to the `insert` function.\n\n```php\n$data = array('id' =\u003e 123, 'name' =\u003e 'bob');\n\necho $db-\u003efrom('user')\n  -\u003einsert($data)\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nINSERT INTO user (id,name) VALUES (123,'bob')\n```\n\n### Update Queries\n\nTo build an update query, pass in an array of data to the `update` function.\n\n```php\n$data = array('name' =\u003e 'bob', 'email' =\u003e 'bob@aol.com');\n$where = array('id' =\u003e 123);\n\necho $db-\u003efrom('user')\n  -\u003ewhere($where)\n  -\u003eupdate($data)\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nUPDATE user SET name='bob',email='bob@aol.com' WHERE id=123\n```\n\n### Delete Queries\n\nTo build a delete query, use the `delete` function.\n\n```php\necho $db-\u003efrom('user')\n  -\u003ewhere('id', 123)\n  -\u003edelete()\n  -\u003esql();\n```\n\nOutput:\n\n```sql\nDELETE FROM user WHERE id=123\n```\n\n## Executing Queries\n\nSparrow can also execute the queries it builds. You will need to call the `setDb()` method with either\na connection string, an array of connection information, or a connection object.\n\nThe supported database types are `mysql`, `mysqli`, `pgsql`, `sqlite` and `sqlite3`.\n\nUsing a connection string:\n\n```php\n$db-\u003esetDb('mysql://admin:hunter2@localhost/mydb');\n```\n\nThe connection string uses the following format:\n\n```\ntype://username:password@hostname[:port]/database\n```\n\nFor sqlite, you need to use:\n\n```\ntype://database\n```\n\nUsing a connection array:\n\n```php\n$db-\u003esetDb(array(\n  'type' =\u003e 'mysql',\n  'hostname' =\u003e 'localhost',\n  'database' =\u003e 'mydb',\n  'username' =\u003e 'admin',\n  'password' =\u003e 'hunter2'\n));\n```\n\nThe possible array options are `type`, `hostname`, `database`, `username`, `password`, and `port`.\n\nUsing a connection object:\n\n```php\n$mysql = new mysqli('localhost', 'admin', 'hunter2');\n\n$mysql-\u003eselect_db('mydb');\n\n$db-\u003esetDb($mysql);\n```\n\nYou can also use PDO for the database connection. To use the connection string or array method, prefix the database type with `pdo`:\n\n```php\n$db-\u003esetDb('pdomysql://admin:hunter2@localhost/mydb');\n```\n\nThe possible PDO types are `pdomysql`, `pdopgsql`, and `pdosqlite`.\n\nYou can also pass in any PDO object directly:\n\n```php\n$pdo = new PDO('mysql:host=localhost;dbname=mydb', 'admin', 'hunter2');\n\n$db-\u003esetDb($pdo);\n```\n\n### Fetching records\n\nTo fetch multiple records, use the `many` function.\n\n```php\n$rows = $db-\u003efrom('user')\n  -\u003ewhere('id \u003e', 100)\n  -\u003emany();\n```\n\nThe result returned is an array of associative arrays:\n\n```php\narray(\n  array('id' =\u003e 101, 'name' =\u003e 'joe'),\n  array('id' =\u003e 102, 'name' =\u003e 'ted');\n)\n```\n\nTo fetch a single record, use the `one` function.\n\n```php\n$row = $db-\u003efrom('user')\n  -\u003ewhere('id', 123)\n  -\u003eone();\n```\n\nThe result returned is a single associative array:\n\n```php\narray('id' =\u003e 123, 'name' =\u003e 'bob')\n```\n\nTo fetch the value of a column, use the `value` function and pass in the name of the column.\n\n```php\n$username = $db-\u003efrom('user')\n  -\u003ewhere('id', 123)\n  -\u003evalue('username');\n```\n\nAll the fetch functions automatically perform a select, so you don't need to include the `select` function\nunless you want to specify the fields to return.\n\n```php\n$row = $db-\u003efrom('user')\n  -\u003ewhere('id', 123)\n  -\u003eselect(array('id', 'name'))\n  -\u003eone();\n```\n\n### Non-queries\n\nFor non-queries like update, insert and delete, use the `execute` function after building your query.\n\n```php\n$db-\u003efrom('user')\n  -\u003ewhere('id', 123)\n  -\u003edelete()\n  -\u003eexecute();\n```\n\nExecutes:\n\n```sql\nDELETE FROM user WHERE id = 123\n```\n\n### Custom Queries\n\nYou can also run raw SQL by passing it to the `sql` function.\n\n```php\n$posts = $db-\u003esql('SELECT * FROM posts')-\u003emany();\n\n$user = $db-\u003esql('SELECT * FROM user WHERE id = 123')-\u003eone();\n\n$db-\u003esql('UPDATE user SET name = 'bob' WHERE id = 1')-\u003eexecute();\n```\n\n### Escaping Values\n\nSparrow's SQL building functions automatically quote and escape values to prevent SQL injection.\nTo quote and escape values manually, like when you're writing own queries, you can use the `quote` function.\n\n```php\n$name = \"O'Dell\";\n\nprintf(\"SELECT * FROM user WHERE name = %s\", $db-\u003equote($name));\n```\n\nOutput:\n\n```sql\nSELECT * FROM user WHERE name = 'O\\'Dell'\n```\n\n### Query Properties\n\nAfter executing a query, several property values will be populated which you can access directly.\n\n```php\n// Last query executed\n$db-\u003elast_query;\n\n// Number of rows returned\n$db-\u003enum_rows;\n\n// Last insert id\n$db-\u003einsert_id;\n\n// Number of affected rows\n$db-\u003eaffected_rows;\n```\n\nThese values are reset every time a new query is executed.\n\n### Helper Methods\n\nTo get a count of rows in a table.\n\n```php\n$count = $db-\u003efrom('user')-\u003ecount();\n```\n\nTo get the minimum value from a table.\n\n```php\n$min = $db-\u003efrom('employee')-\u003emin('salary');\n```\n\nTo get the maximum value from a table.\n\n```php\n$max = $db-\u003efrom('employee')-\u003emax('salary');\n```\n\nTo get the average value from a table.\n\n```php\n$avg = $db-\u003efrom('employee')-\u003eavg('salary');\n```\n\nTo get the sum value from a table.\n\n```php\n$avg = $db-\u003efrom('employee')-\u003esum('salary');\n```\n\n### Direct Access\n\nYou can also access the database object directly by using the  `getDb` function.\n\n```php\n$mysql = $db-\u003egetDb();\n\n$mysql-\u003einfo;\n```\n\n## Caching\n\nTo enable caching, you need to use the `setCache` method with a connection string or connection object.\n\nUsing a connection string:\n\n```php\n$db-\u003esetCache('memcache://localhost:11211');\n```\n\nUsing a cache object:\n\n```php\n$cache = new Memcache;\n$cache-\u003eaddServer('localhost', 11211);\n\n$db-\u003esetCache($cache);\n```\n\nYou can then pass a cache key to the query functions and Sparrow will try to fetch from the cache before\nexecuting the query. If there is a cache miss, Sparrow will execute the query and store the results\nusing the specified cache key.\n\n```php\n$key = 'all_users';\n\n$users = $db-\u003efrom('user')-\u003emany($key);\n```\n\n### Cache Types\n\nThe supported caches are `memcache`, `memcached`, `apc`, `xcache`, `file` and `memory`.\n\nTo use `memcache` or `memcached`, you need to use the following connection string:\n\nprotocol://hostname:port\n\nTo use `apc` or `xcache`, just pass in the cache name:\n\n```php\n$db-\u003esetCache('apc');\n```\n\nTo use the filesystem as a cache, pass in a directory path:\n\n```php\n$db-\u003esetCache('/usr/local/cache');\n\n$db-\u003esetCache('./cache');\n```\n\nNote that local directories must be prefixed with `./`.\n\nThe default cache is `memory` and only lasts the duration of the script.\n\n### Cache Expiration\n\nTo cache data only for a set period of time, you can pass in an additional parameter which represents the expiraton time in seconds.\n\n```php\n$key = 'top_users';\n$expire = 600;\n\n$users = $db-\u003efrom('user')\n  -\u003esortDesc('score')\n  -\u003elimit(100)\n  -\u003emany($key, $expire);\n```\n\nIn the above example, we are getting a list of the top 100 highest scoring users and caching it for 600 seconds (10 minutes).\nYou can pass the expiration parameter to any of the query methods that take a cache key parameter.\n\n### Direct Access\n\nYou can access the cache object directly by using the `getCache` function.\n\n```php\n$memcache = $db-\u003egetCache();\n\necho $memcache-\u003egetVersion();\n```\n\nYou can manipulate the cache data directly as well. To cache a value use the `store` function.\n\n```php\n$db-\u003estore('id', 123);\n```\n\nTo retrieve a cached value use the `fetch` function.\n\n```php\n$id = $db-\u003efetch('id');\n```\n\nTo delete a cached value use the `clear` function.\n\n```php\n$db-\u003eclear('id');\n```\n\nTo completely empty the cache use the `flush` function.\n\n```php\n$db-\u003eflush();\n```\n\n## Using Objects\n\nSparrow also provides some functionality for working with objects. Just define a class with public properties to\nrepresent database fields and static variables to describe the database relationship.\n\n```php\nclass User {\n  // Class properties\n  public $id;\n  public $name;\n  public $email;\n\n  // Class configuration\n  static $table = 'user';\n  static $id_field = 'id';\n  static $name_field = 'name';\n}\n```\n\n### Class Configuration\n\n* The `table` property represents the database table. This property is required. \n* The `id_field` property represents the auto-incrementing identity field in the table. This property is required for saving and deleting records. \n* The `name_field` property is used for finding records by name. This property is optional.\n\n### Loading Objects\n\nTo define the object use the `using` function and pass in the class name.\n\n```php\n$db-\u003eusing('User');\n```\n\nAfter setting your object, you can then use the `find` method to populate the object. If you pass in an int\nSparrow will search using the id field.\n\n```php\n$user = $db-\u003efind(123);\n```\n\nThis will execute:\n\n```sql\nSELECT * FROM user WHERE id = 123\n```\n\nIf you pass in a string Sparrow will search using the name field.\n\n```php\n$user = $db-\u003efind('Bob');\n```\n\nThis will execute:\n\n```sql\nSELECT * FROM user WHERE name = 'Bob';\n```\n\nIf you pass in an array Sparrow will use the fields specified in the array.\n\n```php\n$user = $db-\u003efind(\n  array('email' =\u003e 'bob@aol.com')\n);\n```\n\nThis will execute:\n\n```sql\nSELECT * FROM user WHERE email = 'bob@aol.com'\n```\n\nIf the `find` method retrieves multiple records, it will return an array of objects\ninstead of a single object.\n\n### Saving Objects\n\nTo save an object, just populate your object properties and use the `save` function.\n\n```php\n$user = new User();\n$user-\u003ename = 'Bob';\n$user-\u003eemail = 'bob@aol.com';\n\n$db-\u003esave($user);\n```\n\nThis will execute:\n\n```sql\nINSERT INTO user (name, email) VALUES ('Bob', 'bob@aol.com')\n```\n\nTo update an object, use the `save` function with the `id_field` property populated.\n\n```php\n$user = new User();\n$user-\u003eid = 123;\n$user-\u003ename = 'Bob';\n$user-\u003eemail = 'bob@aol.com';\n\n$db-\u003esave($user);\n```\n\nThis will execute:\n\n```sql\nUPDATE user SET name = 'Bob', email = 'bob@aol.com' WHERE id = 123\n```\n\nTo update an existing record, just fetch an object from the database, update its properties, then save it.\n\n```php\n// Fetch an object from the database\n$user = $db-\u003efind(123);\n\n// Update the object\n$user-\u003ename = 'Fred';\n\n// Update the database\n$db-\u003esave($user);\n```\n\nBy default, all of the object's properties will be included in the update. To specify only specific fields, pass in\nan additional array of fields to the `save` function.\n\n```php\n$db-\u003esave($user, array('email'));\n```\n\nThis will execute:\n\n```sql\nUPDATE user SET email = 'bob@aol.com' WHERE id = 123\n```\n\n### Deleting Objects\n\nTo delete an object, use the `remove` function.\n\n```php\n$user = $db-\u003efind(123);\n\n$db-\u003eremove($user);\n```\n\n### Advanced Finding\n\nYou can use the sql builder functions to further define criteria for loading objects.\n\n```php\n$db-\u003eusing('User')\n  -\u003ewhere('id \u003e', 10)\n  -\u003esortAsc('name')\n  -\u003efind();\n```\n\nThis will execute:\n\n```sql\nSELECT * FROM user WHERE id \u003e 10 ORDER BY name ASC\n```\n\nYou can also pass in raw SQL to load your objects.\n\n```php\n$db-\u003eusing('User')\n  -\u003esql('SELECT * FROM user WHERE id \u003e 10')\n  -\u003efind();\n```\n\n## Statistics\n\nSparrow has built in query statistics tracking. To enable it, just set the `stats_enabled` property.\n\n```php\n$db-\u003estats_enabled = true;\n```\n\nAfter running your queries, get the stats array:\n\n```php\n$stats = $db-\u003egetStats();\n```\n\nThe stats array contains the total time for all queries and an array of all queries executed\nwith individual query times.\n\n```php\narray(6) {\n  [\"queries\"]=\u003e\n  array(2) {\n    [0]=\u003e\n    array(4) {\n      [\"query\"]=\u003e\n        string(38) \"SELECT * FROM user WHERE uid=1\"\n      [\"time\"]=\u003e\n        float(0.00016617774963379)\n      [\"rows\"]=\u003e\n        int(1)\n      [\"changes\"]=\u003e\n        int(0)\n    }\n    [1]=\u003e\n    array(4) {\n      [\"query\"]=\u003e\n        string(39) \"SELECT * FROM user WHERE uid=10\"\n      [\"time\"]=\u003e\n        float(0.00026392936706543)\n      [\"rows\"]=\u003e\n        int(0)\n      [\"changes\"]=\u003e\n        int(0)\n    }\n  }\n  [\"total_time\"]=\u003e\n    float(0.00043010711669922)\n  [\"num_queries\"]=\u003e\n    int(2)\n  [\"num_rows\"]=\u003e\n    int(2)\n  [\"num_changes\"]=\u003e\n    int(0)\n  [\"avg_query_time\"]=\u003e\n    float(0.00021505355834961)\n}\n```\n\n## Debugging\n\nWhen Sparrow encounters an error while executing a query, it will raise an exception with the database\nerror message. If you want to display the generated SQL along with the error message, set the `show_sql` property.\n\n```php\n$db-\u003eshow_sql = true;\n```\n\n## License\n\nSparrow is released under the [MIT](https://github.com/mikecao/sparrow/blob/master/LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikecao%2Fsparrow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikecao%2Fsparrow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikecao%2Fsparrow/lists"}