ORDER BY for Updates/Deletes
This commit is contained in:
parent
38f5daba6b
commit
773286bd06
@ -234,7 +234,7 @@ class Base {
|
||||
protected function updateSingle($id, $field, $table='') {
|
||||
if (empty($table)) $table = $this->table;
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$stmt = $this->mysqli->prepare("UPDATE $table SET " . $field['name'] . " = ? WHERE id = ? LIMIT 1");
|
||||
$stmt = $this->mysqli->prepare("UPDATE $table SET " . $field['name'] . " = ? WHERE id = ? ORDER BY id LIMIT 1");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param($field['type'].'i', $field['value'], $id) && $stmt->execute())
|
||||
return true;
|
||||
$this->debug->append("Unable to update " . $field['name'] . " with " . $field['value'] . " for ID $id");
|
||||
|
||||
@ -145,7 +145,7 @@ class Block extends Base {
|
||||
* @return bool
|
||||
**/
|
||||
public function setConfirmations($block_id, $confirmations) {
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET confirmations = ? WHERE id = ?");
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET confirmations = ? WHERE id = ? ORDER BY id LIMIT 1");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param("ii", $confirmations, $block_id) && $stmt->execute())
|
||||
return true;
|
||||
return $this->sqlError();
|
||||
|
||||
@ -49,7 +49,7 @@ class Payout Extends Base {
|
||||
* @return boolean bool True or False
|
||||
**/
|
||||
public function setProcessed($id) {
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET completed = 1 WHERE id = ?");
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET completed = 1 WHERE id = ? ORDER BY id LIMIT 1");
|
||||
if ($stmt && $stmt->bind_param('i', $id) && $stmt->execute())
|
||||
return true;
|
||||
return $this->sqlError('E0051');
|
||||
|
||||
@ -49,7 +49,7 @@ class Token Extends Base {
|
||||
* @return bool
|
||||
**/
|
||||
public function deleteToken($token) {
|
||||
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE token = ? LIMIT 1");
|
||||
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE token = ? ORDER BY id LIMIT 1");
|
||||
if ($stmt && $stmt->bind_param('s', $token) && $stmt->execute())
|
||||
return true;
|
||||
return $this->sqlError();
|
||||
|
||||
@ -31,7 +31,7 @@ class Worker extends Base {
|
||||
}
|
||||
// Prefix the WebUser to Worker name
|
||||
$value['username'] = "$username." . $value['username'];
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET password = ?, username = ?, monitor = ? WHERE account_id = ? AND id = ?");
|
||||
$stmt = $this->mysqli->prepare("UPDATE $this->table SET password = ?, username = ?, monitor = ? WHERE account_id = ? AND id = ? ORDER BY id LIMIT 1");
|
||||
if ( ! ( $this->checkStmt($stmt) && $stmt->bind_param('ssiii', $value['password'], $value['username'], $value['monitor'], $account_id, $key) && $stmt->execute()) )
|
||||
$iFailed++;
|
||||
}
|
||||
@ -259,7 +259,7 @@ class Worker extends Base {
|
||||
**/
|
||||
public function deleteWorker($account_id, $id) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE account_id = ? AND id = ?");
|
||||
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE account_id = ? AND id = ? ORDER BY id LIMIT 1");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $id) && $stmt->execute() && $stmt->affected_rows == 1)
|
||||
return true;
|
||||
return $this->sqlError('E0061');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user