custom fields in upload.php

This commit is contained in:
xiaomlove
2021-03-03 19:29:29 +08:00
parent 25a69891f4
commit 723a6fadc9
7 changed files with 153 additions and 15 deletions
+10 -3
View File
@@ -152,9 +152,6 @@ class DB
public static function update($table, $data, $whereStr)
{
if (empty($table) || empty($data) || !is_array($data) || empty($whereStr)) {
throw new DatabaseException("require table and data(array) and whereStr.");
}
$updateArr = [];
foreach ($data as $field => $value) {
$updateArr[] = "`$field` = " . sqlesc($value);
@@ -164,6 +161,16 @@ class DB
return mysql_affected_rows();
}
public static function delete($table, $whereStr, $limit = null)
{
$sql = "delete from $table where $whereStr";
if (!is_null($limit)) {
$sql .= " limit $limit";
}
sql_query($sql);
return mysql_affected_rows();
}
public static function getOne($table, $whereStr, $fields = '*')
{
if ($fields != '*') {