array('[table.]rows','Dump one table, use format='),
array('[table.]fields','List fields'),
- array('table.inf','Table infos (count(*). Type, ...)'),
+ array('table.infos','Table infos (count(*). Type, ...)'),
array('table.sql','Get the sql source'),
array('[table.]insert','Insert a record'),
$rows[] = $t->infos();
}
+ usort($rows,function($a,$b) { return strcmp($a['name'],$b['name']); });
$return = $this->out($rows);
} elseif ($action == 'db.conf') {
}
# Table first
- uasort($tables,function($a,$b) use($views){
+ if (0) uasort($tables,function($a,$b) use($views){
#if ($a->type == 'table' and $b->type == 'table') return strcmp($a->name,$b->name);
$embed = function($t) use($views) {
return preg_match('/ FROM .*\b'.join('|',$views).'\b/',$t->sql()) ? 1 : 0;
};
- $cmp = function($t) use($views,$embed) {
- #return preg_match('/ FROM .*\b'.join('|',$views).'\b/',$t->sql()) ? 1 : 0;
- };
-
if ($a->type == 'table' and $b->type !='table') return -1;
if ($a->type != 'table' and $b->type =='table') return +1;
if ($a->type == 'table' and $b->type =='table') return strcmp($a->name,$b->name);
if ($embed($a) and !$embed($b)) return +1;
$diff = strlen($a->name) - strlen($b->name);
if (!$diff) return strcmp($a->name,$b->name);
+echo(">".$a->name."\n");
return ($diff>0 ? +1 : -1);
return;
if ($a->type != 'table') return ($embed($a) ? -1 : +1);
'ip2int' => function ($value) { return ip2long($value); },
'concat' => function ($v1,$v2) { return $v1.$v2; },
'date_format' => function ($date,$format) { return strftime($format,$date); },
+ 'cidr_range' => function ( $cidr, $chkip=null ) { return nb::cidr_range( $cidr,$chkip); },
'regexp' => function ($pattern, $data, $delimiter = '~', $modifiers = 'isuS') {
if (isset($pattern, $data) === true) {
return (preg_match(sprintf('%1$s%2$s%1$s%3$s', $delimiter, $pattern, $modifiers), $data) > 0);
,2),
),
-'tables' => 'SELECT name,type FROM sqlite_master WHERE type IN(\'table\',\'view\') AND name NOT LIKE \'sqlite_%\' ORDER BY name',
+'tables' => "SELECT name,type FROM sqlite_master WHERE type IN('table','view') AND name NOT LIKE 'sqlite_%'",
+#'tables' => 'SELECT name,type FROM sqlite_master WHERE type IN(\'table\',\'view\') AND name NOT LIKE \'sqlite_%\' ORDER BY name',
'table.fields' => array (
'sql' => 'PRAGMA table_info(\'<NAME>\')',