public static function update($id, $data) { foreach ($data as $key => $value) { switch ($key) { case "idParamosPriemones": break; case "Kodas": if (!ParamosPriemonesValidation::validateKodas($value)) { return false; } break; case "Pavadinimas": if (!ParamosPriemonesValidation::validatePavadinimas($value)) { return false; } break; case "Kryptis": if (!ParamosPriemonesValidation::validateKryptis($value)) { return false; } break; } } return parent::update($id, $data, get_class()); }
public static function update($id, $data) { foreach ($data as $key => $value) { switch ($key) { case "idUser": break; case "username": if (!UserValidation::validateUsername($value)) { User::$error = "Inocorrenct username."; return false; } break; case "password": if (!UserValidation::validatePassword($value)) { User::$error = "Inocorrenct password."; return false; } break; } } return parent::update($id, $data, get_class()); }
public static function update($id, $data) { foreach ($data as $key => $value) { //validation switch ($key) { case "idParamosKiekiai": break; case "ParamosPriemone": if (!ParamosKiekiaiValidation::validateParamosPriemone($value)) { return false; } break; case "Nuo": if (!ParamosKiekiaiValidation::validateNuo($value)) { return false; } break; case "Iki": if (!ParamosKiekiaiValidation::validateIki($value)) { return false; } break; case "ParaiskuKiekis": if (!ParamosKiekiaiValidation::validateParaiskuKiekis($value)) { return false; } break; } } return parent::update($id, $data, get_class()); }
protected static function update($id, $data, $class) { $id = repairSqlInjection($id); $class = repairSqlInjection($class); $dbTables = db::getTables(); $query = "UPDATE `PPOS`.`" . $class . "` SET "; $set = ""; foreach ($data as $key => $value) { if (in_array($key, $dbTables[$class])) { $value = repairSqlInjection($value); $key = repairSqlInjection($key); $set .= $key . " = '" . $value . "', "; } } $query .= substr($set, 0, -2); $query .= " WHERE id" . $class . " = " . (int) $id; $result = mysql_query($query); if ($result) { return true; } else { ErrorMessages::setError(6, "update('" . $id . "', array, '" . $class . "')", "MysqlObject.php", $class); MysqlObject::$error = mysql_error(); return false; } }