本文整理汇总了PHP中SQLite3::version方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::version方法的具体用法?PHP SQLite3::version怎么用?PHP SQLite3::version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite3
的用法示例。
在下文中一共展示了SQLite3::version方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ServerInfo
function ServerInfo()
{
$version = SQLite3::version();
$arr['version'] = $version['versionString'];
$arr['description'] = 'SQLite 3';
return $arr;
}
示例2: connect
/**
* Connects to a database.
* @return void
* @throws DibiException
*/
public function connect(array &$config)
{
DibiConnection::alias($config, 'database', 'file');
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
$this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
if (isset($config['resource']) && $config['resource'] instanceof SQLite3) {
$this->connection = $config['resource'];
} else {
try {
$this->connection = new SQLite3($config['database']);
} catch (Exception $e) {
throw new DibiDriverException($e->getMessage(), $e->getCode());
}
}
$this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
$this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
if (strcasecmp($this->dbcharset, $this->charset) === 0) {
$this->dbcharset = $this->charset = NULL;
}
// enable foreign keys support (defaultly disabled; if disabled then foreign key constraints are not enforced)
$version = SQLite3::version();
if ($version['versionNumber'] >= '3006019') {
$this->query("PRAGMA foreign_keys = ON");
}
}
示例3: version
/**
* Database version number
*
* @return string
*/
public function version()
{
if (isset($this->data_cache['version'])) {
return $this->data_cache['version'];
}
$version = SQLite3::version();
return $this->data_cache['version'] = $version['versionString'];
}
示例4: testBatchInsert
public function testBatchInsert()
{
if (version_compare(\SQLite3::version()['versionString'], '3.7.11', '>=')) {
$this->markTestSkipped('This test is only relevant for SQLite < 3.7.11');
}
$sql = $this->getQueryBuilder()->batchInsert('{{customer}} t', ['t.id', 't.name'], [[1, 'a'], [2, 'b']]);
$this->assertEquals("INSERT INTO {{customer}} t (`t`.`id`, `t`.`name`) SELECT 1, 'a' UNION SELECT 2, 'b'", $sql);
}
示例5: getDbInfo
/**
* returns an array with infos about the current database
* The array returned should have tho following structure:
* ["dbserver"]
* ["dbclient"]
* ["dbconnection"]
*
* @return mixed
*/
public function getDbInfo()
{
$arrDB = $this->linkDB->version();
$arrReturn = array();
$arrReturn["dbdriver"] = "sqlite3-extension";
$arrReturn["dbserver"] = "SQLite3 " . $arrDB["versionString"] . " " . $arrDB["versionNumber"];
$arrReturn["dbclient"] = "";
$arrReturn["dbconnection"] = "";
return $arrReturn;
}
示例6: _init
function _init()
{
global $CRUD;
$CRUD['TITLE'] = "CRUD APP";
$CRUD['SELF'] = $_SERVER["SCRIPT_NAME"];
// loose "index.php" if nec (regexes are fugly in php. Feh.)
$CRUD["SELF"] = preg_replace('/([\\/\\\\])index\\.php$/i', '$1', $CRUD["SELF"]);
foreach (array('DBVERSION', 'BUTTONS', 'HIDDENS', 'MESSAGES', 'ERRORS', 'CONTENT', 'PRECONTENT', 'POSTCONTENT', 'Atitle', 'Aartist', 'Alabel', 'Areleased_day', 'Areleased_month', 'Areleased_year', 'Ttrack_number', 'Ttitle', 'Tduration') as $v) {
$CRUD[$v] = '';
}
switch (DBENGINE) {
case 'sqlite3':
try {
$dbh = new PDO('sqlite:' . DBFILE, 'unused', 'unused');
$dbh->sqliteCreateFunction('SEC_TO_TIME', 'sec_to_time', 1);
// custom functions ...
$dbh->sqliteCreateFunction('TIME_TO_SEC', 'time_to_sec', 1);
$dbh->sqliteCreateAggregate('SUM_SEC_TO_TIME', 'sum_sec_to_time_step', 'sum_sec_to_time_finalize', 1);
$CRUD['DBVERSION'] = SQLite3::version();
$CRUD['DBVERSION'] = 'SQLite version ' . $CRUD['DBVERSION']['versionString'];
} catch (PDOException $e) {
error($e->getMessage());
}
break;
case 'mysql':
// connect to the database (persistent)
try {
$dbh = new PDO('mysql:host=localhost;dbname=' . MYSQLDB, MYSQLUSER, MYSQLPASS, array(PDO::ATTR_PERSISTENT => true));
$sth = $dbh->query("SHOW VARIABLES WHERE variable_name = 'version'");
$CRUD['DBVERSION'] = 'MySQL server version ' . $sth->fetchColumn(1);
if ($dbh) {
set_mysql_album_len_function($dbh);
}
} catch (PDOException $e) {
error($e->getMessage());
}
break;
case 'pgsql':
// connect to the database (persistent)
try {
$dbh = new PDO('pgsql:host=localhost;port=5432;dbname=' . PGSQLDB, PGSQLUSER, PGSQLPASS, array(PDO::ATTR_PERSISTENT => true));
$dbh->exec("set client_encoding to 'latin1'");
$sth = $dbh->query('SELECT VERSION()');
$CRUD['DBVERSION'] = explode(' ', $sth->fetchColumn());
$CRUD['DBVERSION'] = 'PostgreSQL server version ' . $CRUD['DBVERSION'][1];
} catch (PDOException $e) {
error($e->getMessage());
}
break;
default:
error('unsupported DBENGINE specified: ' . DBENGINE);
}
$CRUD['dbh'] = $dbh;
}
示例7: sql_server_info
/**
* {@inheritDoc}
*/
public function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false) {
$version = \SQLite3::version();
$this->sql_server_version = $version['versionString'];
if (!empty($cache) && $use_cache) {
$cache->put('sqlite_version', $this->sql_server_version);
}
}
return $raw ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
}
示例8: initialize
/**
* Initializes db specific domain mapping.
*/
protected function initialize()
{
parent::initialize();
$version = \SQLite3::version();
$version = $version['versionString'];
$this->foreignKeySupport = version_compare($version, '3.6.19') >= 0;
$this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, 'DECIMAL'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, 'MEDIUMTEXT'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, 'DATETIME'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, 'BLOB'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, 'MEDIUMBLOB'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, 'LONGBLOB'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, 'LONGBLOB'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, 'LONGTEXT'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, 'MEDIUMTEXT'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, 'MEDIUMTEXT'));
$this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, 'TINYINT'));
}
示例9: testNonDefaultPKOrder
public function testNonDefaultPKOrder()
{
$version = \SQLite3::version();
if (version_compare($version['versionString'], '3.7.16', '<')) {
$this->markTestSkipped('This version of sqlite doesn\'t return the order of the Primary Key.');
}
$this->_conn->executeQuery(<<<EOS
CREATE TABLE non_default_pk_order (
id INTEGER,
other_id INTEGER,
PRIMARY KEY(other_id, id)
)
EOS
);
$tableIndexes = $this->_sm->listTableIndexes('non_default_pk_order');
$this->assertEquals(1, count($tableIndexes));
$this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
$this->assertEquals(array('other_id', 'id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
}
示例10: batchInsert
/**
* Generates a batch INSERT SQL statement.
* For example,
*
* ~~~
* $connection->createCommand()->batchInsert('user', ['name', 'age'], [
* ['Tom', 30],
* ['Jane', 20],
* ['Linda', 25],
* ])->execute();
* ~~~
*
* Note that the values in each row must match the corresponding column names.
*
* @param string $table the table that new rows will be inserted into.
* @param array $columns the column names
* @param array $rows the rows to be batch inserted into the table
* @return string the batch INSERT SQL statement
*/
public function batchInsert($table, $columns, $rows)
{
// SQLite supports batch insert natively since 3.7.11
// http://www.sqlite.org/releaselog/3_7_11.html
if (version_compare(\SQLite3::version()['versionString'], '3.7.11', '>=')) {
return parent::batchInsert($table, $columns, $rows);
}
$schema = $this->db->getSchema();
if (($tableSchema = $schema->getTableSchema($table)) !== null) {
$columnSchemas = $tableSchema->columns;
} else {
$columnSchemas = [];
}
$values = [];
foreach ($rows as $row) {
$vs = [];
foreach ($row as $i => $value) {
if (!is_array($value) && isset($columnSchemas[$columns[$i]])) {
$value = $columnSchemas[$columns[$i]]->dbTypecast($value);
}
if (is_string($value)) {
$value = $schema->quoteValue($value);
} elseif ($value === false) {
$value = 0;
} elseif ($value === null) {
$value = 'NULL';
}
$vs[] = $value;
}
$values[] = implode(', ', $vs);
}
foreach ($columns as $i => $name) {
$columns[$i] = $schema->quoteColumnName($name);
}
return 'INSERT INTO ' . $schema->quoteTableName($table) . ' (' . implode(', ', $columns) . ') SELECT ' . implode(' UNION SELECT ', $values);
}
示例11: GetDBVer
public function GetDBVer($dbname)
{
if (empty($dbname)) {
return '错误';
}
switch ($dbname) {
case 'mysql':
if (function_exists("mysql_get_server_info")) {
$s = @mysql_get_server_info();
$s = $s ? ' mysql_server 版本:' . $s : '';
$c = @mysql_get_client_info();
$c = $c ? ' mysql_client 版本:' . $c : '';
return $s . $c;
}
return '';
break;
case 'sqlite':
if (extension_loaded('sqlite3')) {
$sqliteVer = SQLite3::version();
$str = '<font color=green>√</font>';
$str .= 'SQLite3 Ver' . $sqliteVer['versionString'];
} else {
$str = $this->isfun('sqlite_close');
if (strpos($str, '√') !== false) {
$str .= ' 版本:' . sqlite_libversion();
}
}
return $str;
break;
default:
return '';
break;
}
}
示例12: umask
print "<td style=\" color: #00ff00; \">OK";
}
} else {
print "<td style=\" color: #00ff00; \">OK";
}
umask($oldumask);
print "</td></tr>\n<tr><td>Checking SQLite 2 ...</td>";
if (function_exists('sqlite_escape_string')) {
print "<td style=\" color: #00ff00; \">Installed, version " . sqlite_libversion();
} else {
print "<td style=\" color: #ff0000; \">No SQLite 2 installed!";
// $ok=false;
}
print "</td></tr>\n<tr><td>Checking SQLite 3 ...</td>";
if (defined('SQLITE3_ASSOC')) {
$res = SQLite3::version();
print "<td style=\" color: #00ff00; \">Installed, version " . $res['versionString'];
} else {
print "<td style=\" color: #ff0000; \">No SQLite 3 installed!";
// $ok=false;
}
print "</td></tr>\n<tr><td>Creating data/index.html...</td>";
if ($fp = @fopen("../data/index.html", "w")) {
fwrite($fp, "<html><head><meta http-equiv=\"refresh\" content=\"0;URL=../index.php\" /></head><body></body></html>");
fclose($fp);
print "<td style=\" color: #00ff00; \">data/index.html created";
} else {
print "<td style=\" color: #ff0000; \">Could not create data/index.html!";
$ok = false;
}
print "</td></tr>\n<tr><td>Creating galeries/index.html...</td>";
示例13: getAttribute
public function getAttribute($id)
{
switch ($id) {
case self::ATTR_CLIENT_VERSION:
case self::ATTR_SERVER_VERSION:
$v = SQLite3::version();
return $v['versionString'];
}
return "";
}
示例14: sqlite_libversion
echo "class='tab'";
}
echo ">Vacuum</a>";
echo "<div style='clear:both;'></div>";
echo "<div id='main'>";
if ($view == "structure") {
echo "<b>Database name</b>: " . $db->getName() . "<br/>";
echo "<b>Path to database</b>: " . $db->getPath() . "<br/>";
echo "<b>Size of database</b>: " . $db->getSize() . "<br/>";
echo "<b>Database last modified</b>: " . $db->getDate() . "<br/>";
if ($db->getType() == "SQLiteDatabase") {
echo "<b>SQLite version</b>: " . sqlite_libversion() . "<br/>";
echo "<b>SQLite encoding</b>: " . sqlite_libencoding() . "<br/>";
}
if ($db->getType() == "SQLite3") {
echo "<b>SQLite version</b>: " . SQLite3::version() . "<br/>";
} else {
echo "<b>SQLite version</b>: " . $db->getVersion() . "<br/>";
}
echo "<b>SQLite extension</b>: " . $db->getType() . "<br/>";
echo "<b>PHP version</b>: " . phpversion() . "<br/><br/>";
$query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";
$result = $db->selectArray($query);
$j = 0;
for ($i = 0; $i < sizeof($result); $i++) {
if (substr($result[$i]['name'], 0, 7) != "sqlite_" && $result[$i]['name'] != "") {
$j++;
}
}
if ($j == 0) {
echo "No tables in database.<br/><br/>";
示例15: isfun
<td>dBASE 数据库:</td>
<td><?php
echo isfun("dbase_close");
?>
</td>
<td>mSQL 数据库:</td>
<td><?php
echo isfun("msql_close");
?>
</td>
</tr>
<tr>
<td>SQLite 数据库:</td>
<td><?php
if (extension_loaded('sqlite3')) {
$sqliteVer = SQLite3::version();
echo '<font color=green>√</font> ';
echo "SQLite3 Ver ";
echo $sqliteVer[versionString];
} else {
echo isfun("sqlite_close");
if (isfun("sqlite_close") == '<font color="green">√</font>') {
echo " 版本: " . @sqlite_libversion();
}
}
?>
</td>
<td>Hyperwave 数据库:</td>
<td><?php
echo isfun("hw_close");
?>