public $tables = array();
public $conn;
+ public $title;
public $type;
public $help_criterias = array(
' * or % for wildcar',
' combine criterias with OR/AND',
);
- function __construct($pdo) {
- $this->conn = new PDO($pdo);
- $this->type = strtolower(preg_replace('/^([^:]+):.*$/','\1',$pdo));
+ function __construct($db) {
+
+ $db = is_scalar($db) ? array('conn' => $db) : $db;
+ foreach ($db as $k=>$v) $this->$k = $v;
+ $this->type = strtolower(preg_replace('/^([^:]+):.*$/','\1',$db['conn']));
+
+ #bye($db['conn']);
+ $this->conn = new PDO($db['conn']);
if ($this->type == 'sqlite') {
+ if (empty($this->title)) $this->title = preg_replace('/^.*?:.*(.*?)(\.\w+)?$/','\1',$db['conn']);
+
$this->conn->sqliteCreateFunction('regexp',
function ($pattern, $data, $delimiter = '~', $modifiers = 'isuS') {
if (isset($pattern, $data) === true) {
function print_header($type) {
if ($this->p('format')=='csv') {
- header('Content-type: text/plain');
+ header('Content-type: text/csv');
} elseif ($this->p('format')=='yaml') {
header('Content-type: text/yaml');
}
function rows_rec_div($row) {
+
echo '<ul class="border rad bgcolor">';
foreach ($row as $k => $v) {
echo '<li>'
- .'<span class="key">'.$k.'</span>'
+ .'<span class="k">'.$k.'</span>'
.': '
- .'<span class="value">'.$v.'</span>'
+ .'<span class="v">'.$v.'</span>'
.'</li>';
}
/*
Create
*/
- function Page($opt = array()) {
+ function __construct($opt = array()) {
//// opt
foreach ($opt as $k => $v) {
// Defaults
if ( ! isset($opt['title']) )
#$this->title = $GLOBALS['argv'][0]
- $this->title = $this->filename2title($_SERVER['SCRIPT_NAME']);
+ $this->title = $this->filename2title();
+ #bye($this->title);
#$this->title = preg_replace('@^.*?([^/\.]+)[^/]*@','\1',$_SERVER['SCRIPT_NAME']);
#die( $this->title);
;
return (is_array($v) ? $v : array($v));
}
- function filename2title($str) {
- $str = preg_replace('@^.*?([^/\.]+)(/index)?(\..*?)$@','\1',$_SERVER['SCRIPT_NAME']);
+ function filename2title() {
+ $str = preg_replace(',^.*?([^/]+)(\/?.*)?$,','\1',$_SERVER['REQUEST_URI']);
+ if ($str == '/') $str = preg_replace('@^.*?([^/\.]+)(/index)?(\..*?)$@','\1',$_SERVER['SCRIPT_NAME']);
$str = preg_replace('@[\'_-]+$@',' ',$str);
return mb_strtoupper(mb_substr($str,0,1)).mb_strtolower(mb_substr($str,1,mb_strlen($str)));
}