From: Nicolas Boisselier Date: Tue, 9 Jun 2015 14:55:59 +0000 (+0100) Subject: start function edit X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=0310eec4f3d3c245d36517f3f29dff0883326da6;p=nb.git start function edit --- diff --git a/lib/php/db.php b/lib/php/db.php index c50ee38c..a5787924 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -198,6 +198,7 @@ class table { var $db; var $sql; var $fields = array(); + var $fields_keys = array(); var $extras = array(); var $params = array( 'table', @@ -294,6 +295,30 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. return $this->fields; } + function fields_keys() { + + if (!$this->fields_keys) { + $this->fields_keys = array(); + + foreach ($this->fields() as $name => $f) { + #debug($f); + if ($f['key'] == 1) $this->fields_keys[$name] = $f; + } + + } + + return $this->fields_keys; + + } + + function edit($ids) { + if (!is_array($ids)) $ids = array($ids); + + $sql = "SELECT *" . $this->select_extras(); + $sql .= " FROM $this->name".$this->where_criterias(); + $this->sql = $sql; + } + function debug($msg,$level=0) { if ($level and $level>DEBUG) return;