Exemple #1
0
            $data[":" . $key] = $val;
            unset($data[$key]);
        }
        $result = self::query($sql, $data);
        if (isset($return_field)) {
            return $result->fetchColumn(0);
        } else {
            return (bool) $result;
        }
    }
    public static function update($table, $data, $where)
    {
        $fields = "";
        foreach ($data as $key => $val) {
            $fields .= "\"" . $key . "\" = :" . $key . ", ";
        }
        $sql = "UPDATE \"" . $table . "\" SET " . rtrim($fields, ", ") . " WHERE " . $where;
        foreach ($data as $key => $val) {
            $data[":" . $key] = $val;
            unset($data[$key]);
        }
        $result = self::query($sql, $data);
        return (bool) $result;
    }
    public static function delete($table, $where)
    {
        return (bool) self::query("DELETE FROM \"" . $table . "\" WHERE " . $where);
    }
}
DigiplayDB::connect();