GitHub PullRequestReviewCommentEvent at 2014-05-02 10:08:08
Repository: phpbb
Actor: naderman
Payload: {"comment":{"url":"https://api.github.com/repos/phpbb/phpbb/pulls/comments/12224410","id":12224410,"diff_hunk":"@@ -0,0 +1,375 @@\n+<?php\n+/**\n+*\n+* @package dbal\n+* @copyright (c) 2014 phpBB Group\n+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2\n+*\n+*/\n+\n+namespace phpbb\\db\\driver;\n+\n+/**\n+* SQLite3 Database Abstraction Layer\n+* Minimum Requirement: 3.6.15+\n+* @package dbal\n+*/\n+class sqlite3 extends \\phpbb\\db\\driver\\driver\n+{\n+\t/**\n+\t* @var\tstring\t\tStores errors during connection setup in case the driver is not available\n+\t*/\n+\tprotected $connect_error = '';\n+\n+\t/**\n+\t* @var\t\\SQLite3\tThe SQLite3 database object to operate against\n+\t*/\n+\tprotected $dbo = null;\n+\n+\t/**\n+\t* {@inheritDoc}\n+\t*/\n+\tpublic function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)\n+\t{\n+\t\t$this->persistency = false;\n+\t\t$this->user = $sqluser;\n+\t\t$this->server = $sqlserver . (($port) ? ':' . $port : '');\n+\t\t$this->dbname = $database;\n+\n+\t\tif (!class_exists('SQLite3', false))\n+\t\t{\n+\t\t\t$this->connect_error = 'SQLite3 not found, is the extension installed?';\n+\t\t\treturn $this->sql_error('');\n+\t\t}\n+\n+\t\ttry\n+\t\t{\n+\t\t\t$this->dbo = new \\SQLite3($this->server, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);\n+\t\t\t$this->db_connect_id = true;\n+\t\t}\n+\t\tcatch (Exception $e)\n+\t\t{\n+\t\t\treturn array('message' => $e->getMessage());\n+\t\t}\n+\n+\t\treturn true;\n+\t}\n+\n+\t/**\n+\t* {@inheritDoc}\n+\t*/\n+\tpublic function sql_server_info($raw = false, $use_cache = true)\n+\t{\n+\t\tglobal $cache;\n+\n+\t\tif (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)\n+\t\t{\n+\t\t\t$version = \\SQLite3::version();\n+\n+\t\t\t$this->sql_server_version = $version['versionString'];\n+\n+\t\t\tif (!empty($cache) && $use_cache)\n+\t\t\t{\n+\t\t\t\t$cache->put('sqlite_version', $this->sql_server_version);\n+\t\t\t}\n+\t\t}\n+\n+\t\treturn ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;\n+\t}\n+\n+\t/**\n+\t* SQL Transaction\n+\t*\n+\t* @param\tstring\t$status\t\tShould be one of the following strings:\n+\t*\t\t\t\t\t\t\t\tbegin, commit, rollback\n+\t* @return\tbool\tSuccess/failure of the transaction query\n+\t*/\n+\tprotected function _sql_transaction($status = 'begin')\n+\t{\n+\t\tswitch ($status)\n+\t\t{\n+\t\t\tcase 'begin':\n+\t\t\t\treturn $this->dbo->exec('BEGIN IMMEDIATE');\n+\t\t\tbreak;\n+\n+\t\t\tcase 'commit':\n+\t\t\t\treturn $this->dbo->exec('COMMIT');\n+\t\t\tbreak;\n+\n+\t\t\tcase 'rollback':\n+\t\t\t\treturn $this->dbo->exec('ROLLBACK');\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\treturn true;\n+\t}\n+\n+\t/**\n+\t* {@inheritDoc}\n+\t*/\n+\tpublic function sql_query($query = '', $cache_ttl = 0)\n+\t{\n+\t\tif ($query != '')\n+\t\t{\n+\t\t\tglobal $cache;\n+\n+\t\t\t// EXPLAIN only in extra debug mode\n+\t\t\tif (defined('DEBUG'))\n+\t\t\t{\n+\t\t\t\t$this->sql_report('start', $query);\n+\t\t\t}\n+\n+\t\t\t$this->last_query_text = $query;\n+\t\t\t$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;\n+\t\t\t$this->sql_add_num_queries($this->query_result);\n+\n+\t\t\tif ($this->query_result === false)\n+\t\t\t{\n+\t\t\t\tif (($this->query_result = @$this->dbo->query($query)) === false)\n+\t\t\t\t{\n+\t\t\t\t\t$this->sql_error($query);\n+\t\t\t\t}\n+\n+\t\t\t\tif (defined('DEBUG'))\n+\t\t\t\t{\n+\t\t\t\t\t$this->sql_report('stop', $query);\n+\t\t\t\t}\n+\n+\t\t\t\tif ($cache && $cache_ttl)\n+\t\t\t\t{\n+\t\t\t\t\t$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\telse if (defined('DEBUG'))\n+\t\t\t{\n+\t\t\t\t$this->sql_report('fromcache', $query);\n+\t\t\t}\n+\t\t}\n+\t\telse\n+\t\t{\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\treturn $this->query_result;\n+\t}\n+\n+\t/**\n+\t* Build LIMIT query\n+\t*\n+\t* @param\tstring\t$query\t\tThe SQL query to execute\n+\t* @param\tint\t\t$total\t\tThe number of rows to select\n+\t* @param\tint\t\t$offset\n+\t* @param\tint\t\t$cache_ttl\tEither 0 to avoid caching or\n+\t*\t\t\t\tthe time in seconds which the result shall be kept in cache\n+\t* @return\tmixed\tBuffered, seekable result handle, false on error\n+\t*/\n+\tprotected function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)\n+\t{\n+\t\t$this->query_result = false;\n+\n+\t\t// if $total is set to 0 we do not want to limit the number of rows\n+\t\tif ($total == 0)\n+\t\t{\n+\t\t\t$total = -1;\n+\t\t}\n+\n+\t\t$query .= \"\\n LIMIT \" . ((!empty($offset)) ? $offset . ', ' . $total : $total);\n+\n+\t\treturn $this->sql_query($query, $cache_ttl);\n+\t}\n+\n+\t/**\n+\t* {@inheritDoc}\n+\t*/\n+\tpublic function sql_affectedrows()\n+\t{\n+\t\treturn ($this->db_connect_id) ? $this->dbo->changes() : false;\n+\t}\n+\n+\t/**\n+\t* {@inheritDoc}\n+\t*/\n+\tpublic function sql_fetchrow($query_id = false)\n+\t{\n+\t\tglobal $cache;\n+\n+\t\tif ($query_id === false)\n+\t\t{\n+\t\t\t$query_id = $this->query_result;\n+\t\t}\n+\n+\t\tif ($cache && !is_object($query_id) && $cache->sql_exists($query_id))\n+\t\t{\n+\t\t\treturn $cache->sql_fetchrow($query_id);\n+\t\t}\n+\n+\t\treturn is_object($query_id) ? $query_id->fetchArray(SQLITE3_ASSOC) : false;\n+\t}\n+\n+\t/**\n+\t* {@inheritDoc}\n+\t*/\n+\tpublic function sql_nextid()\n+\t{\n+\t\treturn ($this->db_connect_id) ? $this->dbo->lastInsertRowID() : false;\n+\t}\n+\n+\t/**\n+\t* {@inheritDoc}\n+\t*/\n+\tpublic function sql_freeresult($query_id = false)\n+\t{\n+\t\tglobal $cache;","path":"phpBB/phpbb/db/driver/sqlite3.php","position":222,"original_position":222,"commit_id":"00fa1eff313fbc0c4d461edf68afdab255d6b364","original_commit_id":"00fa1eff313fbc0c4d461edf68afdab255d6b364","user":{"login":"naderman","id":154844,"avatar_url":"https://avatars.githubusercontent.com/u/154844?","gravatar_id":"9f580202b05cc640aa9297ab7a1ae764","url":"https://api.github.com/users/naderman","html_url":"https://github.com/naderman","followers_url":"https://api.github.com/users/naderman/followers","following_url":"https://api.github.com/users/naderman/following{/other_user}","gists_url":"https://api.github.com/users/naderman/gists{/gist_id}","starred_url":"https://api.github.com/users/naderman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naderman/subscriptions","organizations_url":"https://api.github.com/users/naderman/orgs","repos_url":"https://api.github.com/users/naderman/repos","events_url":"https://api.github.com/users/naderman/events{/privacy}","received_events_url":"https://api.github.com/users/naderman/received_events","type":"User","site_admin":false},"body":"Aren't they services now?","created_at":"2014-05-02T10:08:08Z","updated_at":"2014-05-02T10:08:08Z","html_url":"https://github.com/phpbb/phpbb/pull/2351#discussion_r12224410","pull_request_url":"https://api.github.com/repos/phpbb/phpbb/pulls/2351","_links":{"self":{"href":"https://api.github.com/repos/phpbb/phpbb/pulls/comments/12224410"},"html":{"href":"https://github.com/phpbb/phpbb/pull/2351#discussion_r12224410"},"pull_request":{"href":"https://api.github.com/repos/phpbb/phpbb/pulls/2351"}}}}