]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/table.php
authorDevops <sys@15gifts.com>
Fri, 12 May 2017 15:51:59 +0000 (16:51 +0100)
committerDevops <sys@15gifts.com>
Fri, 12 May 2017 15:51:59 +0000 (16:51 +0100)
lib/php/db/field.php
lib/php/db/table.php
www/dbq/dbq.php
www/dbq/html/default.min.js

index 889e3d0f423a68c0de5c4fff595e474fef19e75d..a2cb070ad98d25cff6cffce5142b9f63638c39db 100644 (file)
@@ -82,7 +82,8 @@ class field extends nb {
     if ($this->extras) {
       $html = '<span class="extra" id="'.$this->name.'">'.$this->out($value).'</span>';
     } elseif (strpos($this->type,'Zbool') !== false) {
-      $html = '<input type="checkbox" name="'.$this->name.'" value="1">Yes <input type="checkbox" name="'.$this->name.'" value="0">No';
+      $html .= '<label>Yes</label><input type="checkbox" name="'.$this->name.'" value="1">';
+      $html .= '<label>Yes</label><input type="checkbox" name="'.$this->name.'" value="0">';
     } else {
       $html = '<'.$tag
         .' name="'.$this->name.'"'
index 9ca0908204032efc154aba683920bb1f5fdb1239..fb0456b02c32f76ec709775a912bb17e2c2a2169 100644 (file)
@@ -1634,18 +1634,13 @@ Class Table extends nb {
     return $this->db()->exec($sql);
   }
 
-  # dbq t=nb.mime_type a=table.update type=application/rss+xml name='RSS - Really Simple Syndication' ext=rss debug=2
   public function update($post,&$info=[]) {
-# NB 30.01.17     if (empty($info['values'])) $info['values'] = [];
 
     $keys = [];
     $keys_values = [];
     $fields = [];
     $fields_values = [];
 
-    #$update = [];
-    #$where = [];
-
     foreach ($this->fields() as $name => $field) {
 
       if (!isset($post[$name])) {
@@ -1660,7 +1655,7 @@ Class Table extends nb {
 
         $_value = isset($post[self::$key_preff.$name]) ? $post[self::$key_preff.$name] : null;
 
-        if ($_value) {# and $_value !== $value) {
+        if ($_value) {
           $fields[] = $name;
           $fields_values[] = $value;
           $keys_values[] = $_value;
@@ -1722,7 +1717,6 @@ Class Table extends nb {
     }
 
     #return $sql;
-    #bye($info);
     if (self::p('debug')) {
       $this->debug($info,1);
       return false;
@@ -1739,7 +1733,7 @@ Class Table extends nb {
     #bye($info);
     #return true;
     #debug($execute);
-    return $query->rowCount();
+    return $info['rowCount'];
 
   }
 
index 0effa376b041170e672dffb63680f60c9a278cf7..fc8f802232a58381d20d0580f4999aee73a314fb 100644 (file)
@@ -254,7 +254,9 @@ class DbQ extends nb {
 
     $values = $add ? array_fill(0,count($keys),'') : explode($this->param_args_sep,$this->params['args']);
 
-    $this->table->html_edit(array_combine($keys,$values),$this->table->base.'/'.($add ? 'insert' : 'update'.'/'.$this->params['args']).'/',$add);
+    $this->table->html_edit(array_combine($keys,$values),
+      $this->table->base . '/' . ($add ? 'insert' : 'update' . '/' . urlencode($this->params['args'])) . '/'
+    ,$add);
   }
 
   public function table_rw() {
index 571552cc9cc66adbb46b2c3abdf3d24f9415d5cc..0302e723fd2eb39a4f54ebd17269c3ad362e0ec9 100644 (file)
@@ -1 +1 @@
-function form_clean(e){var t;for(i=0;i<e.length;i++)t=e.elements[i],"none"!=t.style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action");if("get"!=e.getAttribute("method"))return!0;for(t=0;t<e.length;t++){var r=e[t];r.name&&(""!=r.value&&"undefined"!=r.value&&(n+=(n?"&":"?")+encodeURI(r.name)+"="+encodeURI(r.value)))}return n=("?"==o?"":o)+n,e.reset(),window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;"undefined"!=window._dbq.default_limit&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["table.base"]+"."+this.value),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+".html"),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm<window._dbq.perms.write&&(document.querySelectorAll("form.edit").forEach(function(e){e.setAttribute("onsubmit","return false")}),document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e){e.setAttribute("style","display:none")})),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="'+window._dbq["text.clear"]+'" />'+(window._dbq.perm>=window._dbq.perms.write?'&nbsp;<input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'/add/\'" value="'+window._dbq["text.add"]+'"/>':""))})});
+function form_clean(e){var t;for(i=0;i<e.length;i++)"none"!=(t=e.elements[i]).style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action");if("get"!=e.getAttribute("method"))return!0;for(t=0;t<e.length;t++){var r=e[t];r.name&&(""!=r.value&&"undefined"!=r.value&&(n+=(n?"&":"?")+encodeURI(r.name)+"="+encodeURI(r.value)))}return n=("?"==o?"":o)+n,e.reset(),window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;"undefined"!=window._dbq.default_limit&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["table.base"]+"."+this.value),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+".html"),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm<window._dbq.perms.write&&(document.querySelectorAll("form.edit").forEach(function(e){e.setAttribute("onsubmit","return false")}),document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e){e.setAttribute("style","display:none")})),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="'+window._dbq["text.clear"]+'" />'+(window._dbq.perm>=window._dbq.perms.write?'&nbsp;<input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'/add/\'" value="'+window._dbq["text.add"]+'"/>':""))})});