1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-17 20:01:25 +02:00

Prepare for SQLite

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1192 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2009-10-16 12:26:16 +00:00
parent cc3ae45832
commit 5e01a627f7
8 changed files with 59 additions and 36 deletions

View File

@@ -491,7 +491,7 @@ class Adminer {
</form>
<?php
if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
$tables = get_vals("SHOW TABLES");
$tables = tables_list();
if (!$tables) {
echo "<p class='message'>" . lang('No tables.') . "\n";
} else {

View File

@@ -24,6 +24,15 @@ function idf_unescape($idf) {
return str_replace("``", "`", $idf);
}
/** Escape string to use inside ''
* @param string
* @return string
*/
function escape_string($val) {
global $connection;
return substr($connection->quote($val), 1, -1);
}
/** Escape or unescape string to use inside form []
* @param string
* @param bool
@@ -155,11 +164,10 @@ function unique_idf($row, $indexes) {
* @return string
*/
function where($where) {
global $connection;
$return = array();
foreach ((array) $where["where"] as $key => $val) {
$key = bracket_escape($key, "back");
$return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . " = BINARY " . $connection->quote($val); //! enum and set, columns looking like functions
$return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . " = " . exact_value($val); //! enum and set, columns looking like functions
}
foreach ((array) $where["null"] as $key) {
$key = bracket_escape($key, "back");

View File

@@ -177,6 +177,25 @@ function get_databases($flush = true) {
return $return;
}
function engines() {
global $connection;
$return = array();
$result = $connection->query("SHOW ENGINES");
while ($row = $result->fetch_assoc()) {
if (ereg("YES|DEFAULT", $row["Support"])) {
$return[] = $row["Engine"];
}
}
return $return;
}
/** Get tables list
* @return array
*/
function tables_list() {
return get_vals("SHOW TABLES");
}
/** Get table status
* @param string
* @return array
@@ -315,15 +334,6 @@ function collations() {
return $return;
}
/** Escape string to use inside ''
* @param string
* @return string
*/
function escape_string($val) {
global $connection;
return substr($connection->quote($val), 1, -1);
}
/** Find out if database is information_schema
* @param string
* @return bool
@@ -333,6 +343,15 @@ function information_schema($db) {
return ($connection->server_info >= 5 && $db == "information_schema");
}
/** Return expression for binary comparison
* @param string
* @return string
*/
function exact_value($val) {
global $connection;
return "BINARY " . $connection->quote($val);
}
// value means maximum unsigned length
$types = array();
$structured_types = array();