]> git.joonet.de Git - adminer.git/commitdiff
Driver specific INSERT INTO
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 23 Apr 2010 09:03:27 +0000 (09:03 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Fri, 23 Apr 2010 09:03:27 +0000 (09:03 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1484 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/drivers/mysql.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/edit.inc.php
adminer/include/functions.inc.php

index c429bde4d564d20540b734ac13680f833595145e..e11bd75b2b4ac4013b29a2536475e11de888568c 100644 (file)
@@ -680,6 +680,15 @@ if (!defined("DRIVER")) {
                );
        }
        
+       /** Insert data into table
+       * @param string
+       * @param array
+       * @return bool
+       */
+       function insert_into($table, $set) {
+               return queries("INSERT INTO " . idf_escape($table) . " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")");
+       }
+       
        /** Explain select
        * @param Min_DB
        * @param string
index 611977faad73437c4ad20aa377c23696426ce52f..ae2c5adc13445b7a7a6c41779267930cfe0050bd 100644 (file)
@@ -440,6 +440,10 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu
                );
        }
        
+       function insert_into($table, $set) {
+               return queries("INSERT INTO " . idf_escape($table) . ($set ? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")" : "DEFAULT VALUES"));
+       }
+       
        function explain($connection, $query) {
                return $connection->query("EXPLAIN $query");
        }
index d5cdef560e94d15d7f1b44fe3dafb46f6c37075c..5563912a49d0f7e3bfb6512b683f8230ff3b5207 100644 (file)
@@ -474,6 +474,10 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                );
        }
        
+       function insert_into($table, $set) {
+               return queries("INSERT INTO " . idf_escape($table) . ($set ? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")" : "DEFAULT VALUES"));
+       }
+       
        function explain($connection, $query) {
                return $connection->query("EXPLAIN $query");
        }
index cef053e0fc37f0841f34e6021f83f814bd007bd6..a411585ac809101b9606ac230e446614a2084ad8 100644 (file)
@@ -31,7 +31,7 @@ if ($_POST && !$error && !isset($_GET["select"])) {
                        }
                        query_redirect("UPDATE" . limit1(idf_escape($TABLE) . " SET" . implode(",", $set) . "\nWHERE $where"), $location, lang('Item has been updated.'));
                } else {
-                       query_redirect("INSERT INTO " . idf_escape($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")", $location, lang('Item has been inserted.'));
+                       queries_redirect($location, lang('Item has been inserted.'), insert_into($TABLE, $set));
                }
        }
 }
index 8374b8359c3ffc02d22128ebae510002d0cabdb6..0fda9145772cf4a4f1e1b6c2afc7edf7fa154948 100644 (file)
@@ -193,11 +193,11 @@ function unique_array($row, $indexes) {
 */
 function where($where) {
        $return = array();
-       foreach (array("where", "null") as $type) {
-               foreach ((array) $where[$type] as $key => $val) {
-                       $key = bracket_escape($key, "back");
-                       $return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]|``)+`\\)$~', $key) ? $key : idf_escape($key)) . ($type == "null" ? " IS NULL" : (ereg('\\.', $val) ? " LIKE " . exact_value(addcslashes($val, "%_")) : " = " . exact_value($val))); // LIKE because of floats, but slow with ints //! enum and set, columns looking like functions
-               }
+       foreach ((array) $where["where"] as $key => $val) {
+               $return[] = idf_escape($key) . (ereg('\\.', $val) ? " LIKE " . exact_value(addcslashes($val, "%_")) : " = " . exact_value($val)); // LIKE because of floats, but slow with ints //! enum and set
+       }
+       foreach ((array) $where["null"] as $key) {
+               $return[] = idf_escape($key) . " IS NULL";
        }
        return implode(" AND ", $return);
 }