if (!$name and !empty($this->default_table)) $name = $this->default_table;
if (!$name) bye('table name is empty');
+ if (empty($params) or empty($params['db'])) $params['db'] = $this;
if (empty($this->tables[$name])) {
- $this->tables[$name] = new Table($name,['db'=>$this]+$params);
+ $this->tables[$name] = new Table($name,$params);
} elseif ($params) {
$this->tables[$name]->__construct($name,$params);
}
$return = [];
foreach (explode("\n",file_get_contents($config[0])) as $line) {
-#bye($line);
if (!preg_match('/'.($config[1]).'/',$line,$m)) continue;
foreach ($m as $k=>$v) if (preg_match('/^\d+$/',$k)) unset($m[$k]);
$return = array_replace_recursive($return,$m);
*/
public function db($set=null) {
static $db = null;
+ #if ($set !== null) debug($set->name);
if ($set !== null) $db = $set;
return $db;
}
: false
;
+#debug($this->db()->name);
if ($opt['is_html'] and !$this->p('action') and !$this->p('inc')) {
echo $this->html_menu();
}
} # < rows
- if (!$count) {
- $st->closeCursor();
- return;
- }
+ $st->closeCursor();
+ if (!$count) return;
$this->count = $opt['count'] = $count;
$this->limit = $opt['limit'] = $limit;
echo '</div>'.NB_EOL;
}
- $st->closeCursor();
-
return $count;
}
return $r;
}
- public function __wakeup() {
- global $Db;
- $this->db($Db);
- }
-
public function __sleep() {
return [
'name',
background-color: #3C3C3B;
border-color: #3C3C3B;
border-radius: 4px;
+ padding: 0 0.2em;
}
a:hover,
# Make it work in php_cli
if (empty($_SERVER['DOCUMENT_ROOT'])) $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
#var_export([$_SERVER['REQUEST_URI']]);
-if (empty($_SERVER['SERVER_PROTOCOL'])) $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
function run() {
$params = parse_uri([
#
# Page
require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/page.php');
- $Page = new Page();
+ $Page = new Page([
+ 'css' => '/default.css',
+ ]);
$Page->content_type($Page->ext2mime($params['format']) ? $Page->ext2mime($params['format']) : 'text/plain');
#$Page->content_type('text/plain');
#if ($Page->is('text') and !$Page->is('html')) $Page->content_type('text/plain');
function not_implemented() {
#return http_response_code(501);
+ if (empty($_SERVER['SERVER_PROTOCOL'])) $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
$msg = '501 Not Implemented';
header($_SERVER['SERVER_PROTOCOL'].' '.$msg);
echo "$msg\n";