]> git.nbdom.net Git - nb.git/commitdiff
out no_escape
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Aug 2016 14:42:24 +0000 (16:42 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Aug 2016 14:42:24 +0000 (16:42 +0200)
lib/php/db/types/mysql.php
lib/php/out.php

index d440adad6b6fa39afcf7a84b851ecb2f884cc4ef..60f64996a3fdaa0e17a733b1d136c230f8c659bb 100644 (file)
@@ -22,7 +22,7 @@ $DB_TYPES['mysql'] = array (
 'extra_where' => 'having',
 
 'localFile' => array (getenv('HOME').'/.my.cnf','^(?:user(?:name)?=(?P<user>\\S+)|password=(?P<password>\\S+))'),
-'databases' => "SELECT SCHEMA_NAME as `name`,DEFAULT_CHARACTER_SET_NAME as `encoding`,DEFAULT_COLLATION_NAME as `collate` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('performance_schema','information_schema')",
+'databases' => "SELECT SCHEMA_NAME as `name`,DEFAULT_CHARACTER_SET_NAME as `encoding`,DEFAULT_COLLATION_NAME as `collate` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('performance_schema','information_schema','mysql')",
 
 'table.sql' => 'SHOW CREATE TABLE `<NAME>`',
 'table.sql.index' => "SELECT ".(Db::p('db.type') ? "CONCAT(s.TABLE_NAME,'_',s.INDEX_NAME,'_idx')" : 's.INDEX_NAME')." as name,(CASE NON_UNIQUE WHEN 1 THEN 0 ELSE 1 END) as uniqe,GROUP_CONCAT(COLUMN_NAME) as field FROM INFORMATION_SCHEMA.STATISTICS s LEFT OUTER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON t.TABLE_SCHEMA=s.TABLE_SCHEMA AND t.TABLE_NAME=s.TABLE_NAME  AND s.INDEX_NAME=t.CONSTRAINT_NAME  WHERE 0=0 AND t.CONSTRAINT_NAME IS NULL AND s.TABLE_SCHEMA = '<DB>' AND s.TABLE_NAME='<NAME>' GROUP BY name ORDER BY SEQ_IN_INDEX",
index da8f6e4ee9d47c025997a2a1e44d9643ad19b3a5..82838444771697366d066c27d4aead25e11fdbf3 100644 (file)
@@ -229,13 +229,13 @@ Class Out extends Nb {
     return ob_get_flush();
   }
 
-  public static function rows($type,&$data,$head=array()) {
+  public static function rows($type,&$data,$head=[],$conf=[]) {
 
     # Ex: for action=tables when header=0
 
     if (is_scalar($data)) $data = array(array($data));
     if (!isset(self::$types[$type])) self::bye("Unknow type: `$type`");
-    $conf = self::$types[$type];
+    $conf = self::$types[$type] + $conf;
 
     #echo $conf['function']($data); return true;
     if (empty($conf['enclose'])) $conf['enclose'] = array('','');
@@ -290,13 +290,13 @@ Class Out extends Nb {
     return;
   }
 
-  public static function format($v,$type=null) {
+  public static function format($v,$type=null,$conf=[]) {
     if ($type === null) $type = self::$type;
     $is_scalar = is_scalar($v);
     $v = self::scalar($v);
     if ($v==='') $is_scalar = true;
 
-    $v = self::escape($v);
+    if (empty($conf['no_escape'])) $v = self::escape($v);
 
     if (!$is_scalar and strpos($type,'html') !== false) $v = '<pre>'.NB_EOL.$v.NB_EOL.'</pre>';
     return $v;
@@ -400,7 +400,7 @@ function out_tag(&$row,&$o) {
 
   foreach ($row as $k => $v) {
 
-    $v = out::format($v);
+    $v = out::format($v,null,$o);
 
     # Inside tag, ex: label
     if (isset($o['tag_key'])) {