Esempio n. 1
0
 public static function doCall($table, $data, $debug = false)
 {
     $DBobject = parent::init();
     foreach ($data as $key => $value) {
         $key = self::escape($key);
         $value = self::escape($value);
         $keys .= $key . ", ";
         if ($value == null) {
             $values .= "null, ";
         } else {
             $values .= "'" . $value . "', ";
         }
     }
     $keys = rtrim($keys, ', ');
     $values = rtrim($values, ', ');
     $sql = "INSERT INTO {$table} (" . $keys . ") VALUES (" . $values . ")";
     if ($debug == true) {
         $_SESSION['debug'][] = __FUNCTION__ . ': $sql is <strong>' . $sql . '</strong>';
     }
     $DBobject->query($sql);
     if ($DBobject->errno) {
         $_SESSION['errors'][] = '<p>' . __FUNCTION__ . ' failed: ' . $DBobject->error . '<br> statement was: <strong> ' . $sql . '</strong></p>';
     }
     //self::$insertID = self::$db->insert_id;
 }
 public static function doCall($sql, $return = true, $debug = false)
 {
     $DBobject = parent::init();
     //call the database
     $result = $DBobject->query($sql);
     if ($DBobject->errno) {
         $_SESSION['errors'][] = '<p>select failed: ' . $DBobject->error . '<br> statement was: <strong>' . $sql . '</strong></p>';
         return array();
     } elseif ($return == true) {
         $ret = array();
         while ($row = $result->fetch_assoc()) {
             $ret[] = $row;
         }
         return $ret;
     }
     if ($debug == true) {
         logfile::doLog(__FUNCTION__ . ' : $sql is ' . $sql);
     }
 }
Esempio n. 3
0
 public static function doCall($table, $primary, $wnummer, $data, $debug = false)
 {
     $DBobject = parent::init();
     $sql = "UPDATE {$table} SET ";
     foreach ($data as $key => $value) {
         if ($value == null) {
             $sql .= "{$key} = null, ";
         } else {
             $sql .= "{$key} = '{$value}', ";
         }
     }
     $sql = rtrim($sql, ", ");
     $sql .= " WHERE " . $primary . " = '" . $wnummer . "'";
     if ($debug == true) {
         logfile::doLog(__FUNCTION__ . ' : $sql is ' . $sql);
     }
     $DBobject->query($sql);
     if ($DBobject->errno) {
     }
 }