]> git.nbdom.net Git - nb.git/commitdiff
wp
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 5 Aug 2016 09:23:57 +0000 (11:23 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 5 Aug 2016 09:23:57 +0000 (11:23 +0200)
lib/php/db/table.php
lib/php/functions.php
lib/php/nb.php

index 8b2a21abd52d8a4b3f0e24c172320145d104f7c2..e8932f992e6b5b97162ee22f9f2e7d81be117550 100644 (file)
@@ -727,7 +727,7 @@ Class Table extends nb {
     if ($opt_by_val !== null) $opt = $opt_by_val;
 
     $format = $this->p('format');
-    if (!$format) bye("Invalid parameter format!");
+    if (!$format) bye("Parameter `format` missing!");
 
     list($sql,$where,$limit,$select_count) = $this->rows_sql($opt);
     $st = $this->db()->conn->prepare($sql);
index 08856f41037ff343be019048a73389c6d0c99889..4f8515a32950b618b120b8a018c451ea28a1689c 100644 (file)
@@ -12,6 +12,7 @@ s/^define(\([^,]\+\)/if (!defined(\1)) define(\1/
 // NB 28.06.15 require_once((dirname(__FILE__).'/default.php'));
 
 function file_write($file,$data,$mode='w') {
+  return nb::file_write($file,$data,$mode);
 
   if (!$ftmp = fopen($file,$mode)) {
     bye("file_write(): Cant open $file in mode $mode");
index 76be10a4e418e5a2ebc32c62aec2049aeba2436c..36344c7d7ac70fe6453d301782cf5c0fec81e87c 100644 (file)
@@ -578,5 +578,22 @@ class NB {
 
   }
 
+  public static function file_write($file,$data,$mode='w') {
+
+    if (!$ftmp = fopen($file,$mode)) {
+      bye("file_write(): Can't open $file in mode $mode");
+      return;
+    }
+
+    if (fwrite($ftmp,$data) === FALSE) {
+      bye("file_write(): Can't write $file in mode $mode");
+      return;
+    }
+
+    fclose($ftmp);
+    return 1;
+
+  }
+
 } # < Class
 ?>