Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 768 lines (703 sloc) 22.879 kb
3f5b683 Reintegrate sqlite branch
jakubvrana authored
1 <?php
2 $possible_drivers[] = "MySQLi";
3 $possible_drivers[] = "MySQL";
4 $possible_drivers[] = "PDO_MySQL";
5 if (extension_loaded("mysqli") || extension_loaded("mysql") || extension_loaded("pdo_mysql")) {
6 $drivers = array("server" => "MySQL") + $drivers;
7 }
8
9 if (!defined("DRIVER")) {
10 define("DRIVER", "server"); // server - backwards compatibility
11 // MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable
12 if (extension_loaded("mysqli")) {
13 class Min_DB extends MySQLi {
14 var $extension = "MySQLi";
15
16 function Min_DB() {
17 parent::init();
18 }
19
20 function connect($server, $username, $password) {
21 list($host, $port) = explode(":", $server, 2); // part after : is used for port or socket
22 return @$this->real_connect(
23 ($server != "" ? $host : ini_get("mysqli.default_host")),
24 ("$server$username" != "" ? $username : ini_get("mysqli.default_user")),
25 ("$server$username$password" != "" ? $password : ini_get("mysqli.default_pw")),
26 null,
27 (is_numeric($port) ? $port : ini_get("mysqli.default_port")),
28 (!is_numeric($port) ? $port : null)
29 );
30 }
31
32 function result($query, $field = 0) {
33 $result = $this->query($query);
34 if (!$result) {
35 return false;
36 }
37 $row = $result->fetch_array();
38 return $row[$field];
39 }
40
41 function quote($string) {
42 return "'" . $this->escape_string($string) . "'";
43 }
44 }
45
46 } elseif (extension_loaded("mysql")) {
47 class Min_DB {
48 var
49 $extension = "MySQL", ///< @var string extension name
50 $server_info, ///< @var string server version
51 $affected_rows, ///< @var int number of affected rows
52 $error, ///< @var string last error message
53 $_link, $_result ///< @access private
54 ;
55
56 /** Connect to server
57 * @param string
58 * @param string
59 * @param string
60 * @return bool
61 */
62 function connect($server, $username, $password) {
63 $this->_link = @mysql_connect(
64 ($server != "" ? $server : ini_get("mysql.default_host")),
65 ("$server$username" != "" ? $username : ini_get("mysql.default_user")),
66 ("$server$username$password" != "" ? $password : ini_get("mysql.default_password")),
67 true,
68 131072 // CLIENT_MULTI_RESULTS for CALL
69 );
70 if ($this->_link) {
71 $this->server_info = mysql_get_server_info($this->_link);
72 } else {
73 $this->error = mysql_error();
74 }
75 return (bool) $this->_link;
76 }
77
78 /** Quote string to use in SQL
79 * @param string
80 * @return string escaped string enclosed in '
81 */
82 function quote($string) {
83 return "'" . mysql_real_escape_string($string, $this->_link) . "'";
84 }
85
86 /** Select database
87 * @param string
88 * @return bool
89 */
90 function select_db($database) {
91 return mysql_select_db($database, $this->_link);
92 }
93
94 /** Send query
95 * @param string
96 * @param bool
97 * @return mixed bool or Min_Result
98 */
99 function query($query, $unbuffered = false) {
100 $result = @($unbuffered ? mysql_unbuffered_query($query, $this->_link) : mysql_query($query, $this->_link)); // @ - mute mysql.trace_mode
101 if (!$result) {
102 $this->error = mysql_error($this->_link);
103 return false;
104 }
105 if ($result === true) {
106 $this->affected_rows = mysql_affected_rows($this->_link);
107 $this->info = mysql_info($this->_link);
108 return true;
109 }
110 return new Min_Result($result);
111 }
112
113 /** Send query with more resultsets
114 * @param string
115 * @return bool
116 */
117 function multi_query($query) {
118 return $this->_result = $this->query($query);
119 }
120
121 /** Get current resultset
122 * @return Min_Result
123 */
124 function store_result() {
125 return $this->_result;
126 }
127
128 /** Fetch next resultset
129 * @return bool
130 */
131 function next_result() {
132 // MySQL extension doesn't support multiple results
133 return false;
134 }
135
136 /** Get single field from result
137 * @param string
138 * @param int
139 * @return string
140 */
141 function result($query, $field = 0) {
142 $result = $this->query($query);
143 if (!$result) {
144 return false;
145 }
146 return mysql_result($result->_result, 0, $field);
147 }
148 }
149
150 class Min_Result {
151 var
152 $num_rows, ///< @var int number of rows in the result
153 $_result ///< @access private
154 ;
155
156 /** Constructor
157 * @param resource
158 */
159 function Min_Result($result) {
160 $this->_result = $result;
161 $this->num_rows = mysql_num_rows($result);
162 }
163
164 /** Fetch next row as associative array
165 * @return array
166 */
167 function fetch_assoc() {
168 return mysql_fetch_assoc($this->_result);
169 }
170
171 /** Fetch next row as numbered array
172 * @return array
173 */
174 function fetch_row() {
175 return mysql_fetch_row($this->_result);
176 }
177
178 /** Fetch next field
179 * @return object properties: name, type, orgtable, orgname, charsetnr
180 */
181 function fetch_field() {
182 $return = mysql_fetch_field($this->_result);
183 $return->orgtable = $return->table;
184 $return->orgname = $return->name;
185 $return->charsetnr = ($return->blob ? 63 : 0);
186 return $return;
187 }
188
189 /** Free result set
190 */
191 function __destruct() {
192 mysql_free_result($this->_result); //! not called in PHP 4 which is a problem with mysql.trace_mode
193 }
194 }
195
196 } elseif (extension_loaded("pdo_mysql")) {
197 class Min_DB extends Min_PDO {
198 var $extension = "PDO_MySQL";
199
200 function connect($server, $username, $password) {
201 $this->dsn("mysql:host=" . str_replace(":", ";unix_socket=", preg_replace('~:([0-9])~', ';port=\\1', $server)), $username, $password);
202 return true;
203 }
204
205 function select_db($database) {
206 // database selection is separated from the connection so dbname in DSN can't be used
207 return $this->query("USE " . idf_escape($database));
208 }
209
210 function query($query, $unbuffered = false) {
211 $this->setAttribute(1000, !$unbuffered); // 1000 - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
212 return parent::query($query, $unbuffered);
213 }
214 }
215
216 }
217
218 /** Escape database identifier
219 * @param string
220 * @return string
221 */
222 function idf_escape($idf) {
223 return "`" . str_replace("`", "``", $idf) . "`";
224 }
225
226 /** Connect to the database
227 * @return mixed Min_DB or string for error
228 */
229 function connect() {
230 global $adminer;
231 $connection = new Min_DB;
232 $credentials = $adminer->credentials();
233 if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
234 $connection->query("SET SQL_QUOTE_SHOW_CREATE=1");
235 $connection->query("SET NAMES utf8");
236 return $connection;
237 }
238 return $connection->error;
239 }
240
241 /** Get cached list of databases
242 * @param bool
243 * @return array
244 */
245 function get_databases($flush = true) {
246 // SHOW DATABASES can take a very long time so it is cached
247 $return = &get_session("databases");
248 if (!isset($return)) {
249 if ($flush) {
250 restart_session();
251 ob_flush();
252 flush();
253 }
254 $return = get_vals("SHOW DATABASES");
255 }
256 return $return;
257 }
258
259 /** Formulate SQL query with limit
260 * @param string everything after SELECT
261 * @param int
262 * @param int
263 * @return string
264 */
265 function limit($query, $limit, $offset = 0) {
266 return " $query" . (isset($limit) ? "\nLIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
267 }
268
269 /** Formulate SQL modification query with limit 1
270 * @param string everything after UPDATE or DELETE
271 * @return string
272 */
273 function limit1($query) {
274 return limit($query, 1);
275 }
276
277 /** Get database collation
278 * @param string
279 * @param array result of collations()
280 * @return string
281 */
282 function db_collation($db, $collations) {
283 global $connection;
284 $return = null;
285 $create = $connection->result("SHOW CREATE DATABASE " . idf_escape($db), 1);
286 if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) {
287 $return = $match[1];
288 } elseif (preg_match('~ CHARACTER SET ([^ ]+)~', $create, $match)) {
289 // default collation
290 $return = $collations[$match[1]][0];
291 }
292 return $return;
293 }
294
295 /** Get supported engines
296 * @return array
297 */
298 function engines() {
299 global $connection;
300 $return = array();
301 $result = $connection->query("SHOW ENGINES");
302 while ($row = $result->fetch_assoc()) {
303 if (ereg("YES|DEFAULT", $row["Support"])) {
304 $return[] = $row["Engine"];
305 }
306 }
307 return $return;
308 }
309
310 /** Get logged user
311 * @return string
312 */
313 function logged_user() {
314 global $connection;
315 return $connection->result("SELECT USER()");
316 }
317
318 /** Get tables list
319 * @return array
320 */
321 function tables_list() {
322 global $connection;
323 return get_key_vals("SHOW" . ($connection->server_info >= 5 ? " FULL" : "") . " TABLES");
324 }
325
326 /** Count tables in all databases
327 * @param array
328 * @return array array($db => $tables)
329 */
330 function count_tables($databases) {
331 $return = array();
332 foreach ($databases as $db) {
333 $return[$db] = count(get_vals("SHOW TABLES IN " . idf_escape($db)));
334 }
335 return $return;
336 }
337
338 /** Get table status
339 * @param string
340 * @return array
341 */
342 function table_status($name = "") {
343 global $connection;
344 $return = array();
345 $result = $connection->query("SHOW TABLE STATUS" . ($name != "" ? " LIKE " . $connection->quote(addcslashes($name, "%_")) : ""));
346 while ($row = $result->fetch_assoc()) {
347 if ($row["Engine"] == "InnoDB") {
348 // ignore internal comment, unnecessary since MySQL 5.1.21
349 $row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["Comment"]);
350 }
351 if (!isset($row["Rows"])) {
352 $row["Engine"] = "VIEW";
353 $row["Comment"] = "";
354 }
355 if ($name != "") {
356 return $row;
357 }
358 $return[$row["Name"]] = $row;
359 }
360 return $return;
361 }
362
363 /** Check if table supports foreign keys
364 * @param array result of table_status
365 * @return bool
366 */
367 function fk_support($table_status) {
368 return ($table_status["Engine"] == "InnoDB");
369 }
370
371 /** Get information about fields
372 * @param string
373 * @return array array($name => array("field" => , "full_type" => , "type" => , "length" => , "unsigned" => , "default" => , "null" => , "auto_increment" => , "on_update" => , "collation" => , "privileges" => , "comment" => , "primary" => ))
374 */
375 function fields($table) {
376 global $connection;
377 $return = array();
378 $result = $connection->query("SHOW FULL COLUMNS FROM " . idf_escape($table));
379 if ($result) {
380 while ($row = $result->fetch_assoc()) {
381 preg_match('~^([^( ]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
382 $return[$row["Field"]] = array(
383 "field" => $row["Field"],
384 "full_type" => $row["Type"],
385 "type" => $match[1],
386 "length" => $match[2],
387 "unsigned" => ltrim($match[3] . $match[4]),
388 "default" => ($row["Default"] != "" || ereg("char", $match[1]) ? $row["Default"] : null),
389 "null" => ($row["Null"] == "YES"),
390 "auto_increment" => ($row["Extra"] == "auto_increment"),
391 "on_update" => (eregi('^on update (.+)', $row["Extra"], $match) ? $match[1] : ""), //! available since MySQL 5.1.23
392 "collation" => $row["Collation"],
393 "privileges" => array_flip(explode(",", $row["Privileges"])),
394 "comment" => $row["Comment"],
395 "primary" => ($row["Key"] == "PRI"),
396 );
397 }
398 }
399 return $return;
400 }
401
402 /** Get table indexes
403 * @param string
404 * @param string Min_DB to use
405 * @return array array($key_name => array("type" => , "columns" => array(), "lengths" => array()))
406 */
407 function indexes($table, $connection2 = null) {
408 global $connection;
409 if (!is_object($connection2)) { // use the main connection if the separate connection is unavailable
410 $connection2 = $connection;
411 }
412 $return = array();
413 $result = $connection2->query("SHOW INDEX FROM " . idf_escape($table));
414 if ($result) {
415 while ($row = $result->fetch_assoc()) {
416 $return[$row["Key_name"]]["type"] = ($row["Key_name"] == "PRIMARY" ? "PRIMARY" : ($row["Index_type"] == "FULLTEXT" ? "FULLTEXT" : ($row["Non_unique"] ? "INDEX" : "UNIQUE")));
417 $return[$row["Key_name"]]["columns"][] = $row["Column_name"];
418 $return[$row["Key_name"]]["lengths"][] = $row["Sub_part"];
419 }
420 }
421 return $return;
422 }
423
424 /** Get foreign keys in table
425 * @param string
426 * @return array array($name => array("db" => , "table" => , "source" => array(), "target" => array(), "on_delete" => , "on_update" => ))
427 */
428 function foreign_keys($table) {
429 global $connection, $on_actions;
430 static $pattern = '`(?:[^`]|``)+`';
431 $return = array();
432 $create_table = $connection->result("SHOW CREATE TABLE " . idf_escape($table), 1);
433 if ($create_table) {
434 preg_match_all("~CONSTRAINT ($pattern) FOREIGN KEY \\(((?:$pattern,? ?)+)\\) REFERENCES ($pattern)(?:\\.($pattern))? \\(((?:$pattern,? ?)+)\\)(?: ON DELETE (" . implode("|", $on_actions) . "))?(?: ON UPDATE (" . implode("|", $on_actions) . "))?~", $create_table, $matches, PREG_SET_ORDER);
435 foreach ($matches as $match) {
436 preg_match_all("~$pattern~", $match[2], $source);
437 preg_match_all("~$pattern~", $match[5], $target);
438 $return[idf_unescape($match[1])] = array(
439 "db" => idf_unescape($match[4] != "" ? $match[3] : $match[4]),
440 "table" => idf_unescape($match[4] != "" ? $match[4] : $match[3]),
441 "source" => array_map('idf_unescape', $source[0]),
442 "target" => array_map('idf_unescape', $target[0]),
443 "on_delete" => $match[6],
444 "on_update" => $match[7],
445 );
446 }
447 }
448 return $return;
449 }
450
451 /** Get view SELECT
452 * @param string
453 * @return array array("select" => )
454 */
455 function view($name) {
456 global $connection;
f9dd7aa Driver specific trigger options
jakubvrana authored
457 return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU', '', $connection->result("SHOW CREATE VIEW " . idf_escape($name), 1)));
3f5b683 Reintegrate sqlite branch
jakubvrana authored
458 }
459
460 /** Get sorted grouped list of collations
461 * @return array
462 */
463 function collations() {
464 global $connection;
465 $return = array();
466 $result = $connection->query("SHOW COLLATION");
467 while ($row = $result->fetch_assoc()) {
468 $return[$row["Charset"]][] = $row["Collation"];
469 }
470 ksort($return);
471 foreach ($return as $key => $val) {
472 sort($return[$key]);
473 }
474 return $return;
475 }
476
477 /** Find out if database is information_schema
478 * @param string
479 * @return bool
480 */
481 function information_schema($db) {
482 global $connection;
483 return ($connection->server_info >= 5 && $db == "information_schema");
484 }
485
486 /** Get escaped error message
487 * @return string
488 */
489 function error() {
490 global $connection;
491 return h(preg_replace('~^You have an error.*syntax to use~U', "Syntax error", $connection->error));
492 }
493
494 /** Return expression for binary comparison
495 * @param string
496 * @return string
497 */
498 function exact_value($val) {
499 global $connection;
500 return "BINARY " . $connection->quote($val);
501 }
502
edb6401 Driver specific create and drop database
jakubvrana authored
503 /** Create database
504 * @param string
505 * @return string
506 */
507 function create_database($db, $collation) {
508 return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " COLLATE " . $connection->quote($collation) : ""));
509 }
510
511 /** Drop databases
512 * @param array
513 * @return bool
514 */
515 function drop_databases($databases) {
516 foreach ($databases as $db) {
517 if (!queries("DROP DATABASE " . idf_escape($db))) {
518 return false;
519 }
520 }
521 return true;
522 }
523
3f5b683 Reintegrate sqlite branch
jakubvrana authored
524 /** Rename database from DB
525 * @param string new name
526 * @return string
527 * @return bool
528 */
529 function rename_database($name, $collation) {
530 global $connection;
531 $return = false;
edb6401 Driver specific create and drop database
jakubvrana authored
532 if (create_database($name, $collation)) {
3f5b683 Reintegrate sqlite branch
jakubvrana authored
533 //! move triggers
534 $return = true; // table list may by empty
535 foreach (tables_list() as $table) {
536 if (!queries("RENAME TABLE " . idf_escape($table) . " TO " . idf_escape($name) . "." . idf_escape($table))) {
537 $return = false;
538 break;
539 }
540 }
541 if ($return) {
542 queries("DROP DATABASE " . idf_escape(DB));
543 //! saved to history of removed database
544 }
545 }
546 return $return;
547 }
548
549 /** Generate modifier for auto increment column
550 * @return string
551 */
552 function auto_increment() {
553 $auto_increment_index = " PRIMARY KEY";
554 // don't overwrite primary key by auto_increment
555 if ($_GET["create"] != "" && $_POST["auto_increment_col"]) {
556 foreach (indexes($_GET["create"]) as $index) {
557 if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) {
558 $auto_increment_index = "";
559 break;
560 }
561 if ($index["type"] == "PRIMARY") {
562 $auto_increment_index = " UNIQUE";
563 }
564 }
565 }
566 return " AUTO_INCREMENT$auto_increment_index";
567 }
568
569 /** Run commands to create or alter table
570 * @param string "" to create
571 * @param string new name
572 * @param array of array($orig, $process_field, $after)
573 * @param array of strings
574 * @param string
575 * @param string
576 * @param string
577 * @param int
578 * @param string
579 * @return bool
580 */
581 function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
582 global $connection;
583 $alter = array();
584 foreach ($fields as $field) {
585 $alter[] = ($field[1]
586 ? ($table != "" ? ($field[0] != "" ? "CHANGE " . idf_escape($field[0]) : "ADD") : " ") . " " . implode("", $field[1]) . ($table != "" ? " $field[2]" : "")
587 : "DROP " . idf_escape($field[0])
588 );
589 }
590 $alter = array_merge($alter, $foreign);
591 $status = "COMMENT=" . $connection->quote($comment)
592 . ($engine ? " ENGINE=" . $connection->quote($engine) : "")
593 . ($collation ? " COLLATE " . $connection->quote($collation) : "")
594 . ($auto_increment != "" ? " AUTO_INCREMENT=$auto_increment" : "")
595 . $partitioning
596 ;
597 if ($table == "") {
598 return queries("CREATE TABLE " . idf_escape($name) . " (\n" . implode(",\n", $alter) . "\n) $status");
599 }
600 if ($table != $name) {
601 $alter[] = "RENAME TO " . idf_escape($name);
602 }
603 $alter[] = $status;
604 return queries("ALTER TABLE " . idf_escape($table) . "\n" . implode(",\n", $alter));
605 }
606
607 /** Run commands to alter indexes
608 * @param string escaped table name
609 * @param array of array("index type", "(columns definition)") or array("index type", "escaped name", "DROP")
610 * @return bool
611 */
612 function alter_indexes($table, $alter) {
613 foreach ($alter as $key => $val) {
614 $alter[$key] = ($val[2] ? "\nDROP INDEX " : "\nADD $val[0] " . ($val[0] == "PRIMARY" ? "KEY " : "")) . $val[1];
615 }
616 return queries("ALTER TABLE " . idf_escape($table) . implode(",", $alter));
617 }
618
619 /** Run commands to truncate tables
620 * @param array
621 * @return bool
622 */
623 function truncate_tables($tables) {
624 foreach ($tables as $table) {
625 if (!queries("TRUNCATE TABLE " . idf_escape($table))) {
626 return false;
627 }
628 }
629 return true;
630 }
631
632 /** Drop views
633 * @param array
634 * @return bool
635 */
636 function drop_views($views) {
637 return queries("DROP VIEW " . implode(", ", array_map('idf_escape', $views)));
638 }
639
640 /** Drop tables
641 * @param array
642 * @return bool
643 */
644 function drop_tables($tables) {
645 return queries("DROP TABLE " . implode(", ", array_map('idf_escape', $tables)));
646 }
647
648 /** Get information about trigger
649 * @param string trigger name
650 * @return array array("Trigger" => , "Timing" => , "Event" => , "Statement" => )
651 */
652 function trigger($name) {
653 global $connection;
654 $result = $connection->query("SHOW TRIGGERS WHERE `Trigger` = " . $connection->quote($name));
655 return $result->fetch_assoc();
656 }
657
658 /** Get defined triggers
659 * @param string
660 * @return array array($name => array($timing, $event))
661 */
662 function triggers($table) {
663 global $connection;
664 $return = array();
665 $result = $connection->query("SHOW TRIGGERS LIKE " . $connection->quote(addcslashes($table, "%_")));
666 while ($row = $result->fetch_assoc()) {
667 $return[$row["Trigger"]] = array($row["Timing"], $row["Event"]);
668 }
669 return $return;
670 }
671
edb6401 Driver specific create and drop database
jakubvrana authored
672 /** Get trigger options
673 * @return array ("Timing" => array(), "Type" => array())
674 */
f9dd7aa Driver specific trigger options
jakubvrana authored
675 function trigger_options() {
676 return array(
677 "Timing" => array("BEFORE", "AFTER"),
678 // Event is always INSERT, UPDATE, DELETE
679 "Type" => array("FOR EACH ROW"),
680 );
681 }
682
3f5b683 Reintegrate sqlite branch
jakubvrana authored
683 /** Explain select
684 * @param Min_DB
685 * @param string
686 * @return Min_Result
687 */
688 function explain($connection, $query) {
689 return $connection->query("EXPLAIN $query");
690 }
691
692 /** Get SQL command to create table
693 * @param string
694 * @return string
695 */
696 function create_sql($table) {
697 global $connection;
698 return $connection->result("SHOW CREATE TABLE " . idf_escape($table), 1);
699 }
700
58c80e3 Driver specific USE
jakubvrana authored
701 /** Get SQL command to change database
702 * @param string
703 * @return string
704 */
705 function use_sql($database) {
706 return "USE " . idf_escape($database);
707 }
708
709 /** Get server variables
710 * @return array ($name => $value)
711 */
984d090 SQLite variables
jakubvrana authored
712 function show_variables() {
713 return get_key_vals("SHOW VARIABLES");
714 }
715
58c80e3 Driver specific USE
jakubvrana authored
716 /** Get status variables
717 * @return array ($name => $value)
718 */
984d090 SQLite variables
jakubvrana authored
719 function show_status() {
720 return get_key_vals("SHOW STATUS");
721 }
722
3f5b683 Reintegrate sqlite branch
jakubvrana authored
723 /** Check whether a feature is supported
724 * @param string
725 * @return bool
726 */
727 function support($feature) {
728 global $connection;
729 $features = array(
730 "view" => ($connection->server_info >= 5),
731 "routine" => ($connection->server_info >= 5),
732 "trigger" => ($connection->server_info >= 5),
733 "event" => ($connection->server_info >= 5.1),
734 "partitioning" => ($connection->server_info >= 5.1),
735 );
736 return (isset($features[$feature]) ? $features[$feature] : true);
737 }
738
739 $driver = "sql"; ///< @var string JUSH identifier
740 $types = array(); ///< @var array ($type => $maximum_unsigned_length, ...)
741 $structured_types = array(); ///< @var array ($description => array($type, ...), ...)
742 foreach (array(
743 lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21),
744 lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4),
745 lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295),
746 lang('Binary') => array("binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295),
747 lang('Lists') => array("enum" => 65535, "set" => 64),
748 ) as $key => $val) {
749 $types += $val;
750 $structured_types[$key] = array_keys($val);
751 }
752 $unsigned = array("unsigned", "zerofill", "unsigned zerofill"); ///< @var array number variants
753 $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL"); ///< @var array operators used in select
754 $functions = array("char_length", "from_unixtime", "hex", "lower", "round", "sec_to_time", "time_to_sec", "upper"); ///< @var array functions used in select
755 $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"); ///< @var array grouping functions used in select
756 $edit_functions = array( ///< @var array of array("$type|$type2" => "$function/$function2") functions used in editing, [0] - edit and insert, [1] - edit only
757 array(
758 "char" => "md5/sha1/password/encrypt/uuid", //! JavaScript for disabling maxlength
759 "date|time" => "now",
760 ), array(
761 "int|float|double|decimal" => "+/-",
762 "date" => "+ interval/- interval",
763 "time" => "addtime/subtime",
764 "char|text" => "concat",
765 )
766 );
767 }
Something went wrong with that request. Please try again.