php - Why does this UPDATE procedure update every row? -


i have mysql stored procedure this

update `discounts` set `occupation`=occupation, `organization`=organization, `lastname`=lastname, `firstname`=firstname, `email`=email, `phone`=phone, `description`=description, `expirationdate`=expiration, `notes`=notes    `id` = id 

and i'm calling php

$occupation = $_post["occupation"]; $organization = $_post["organization"]; $last = $_post["last"];  $first = $_post["first"];  $email = $_post["email"]; $phone = $_post["phone"];  $description = $_post["description"]; $notes = $_post["notes"]; $expiration = date("y-m-d h:i:s", strtotime($_post["expiration"])); $id = intval($_post["id"], 10);  $password = $_post["password"];  $mysqli = new mysqli("localhost", "xxx", $password, "xxxxxxxx"); if ($mysqli->connect_errno) {     die("could not connect"); } $stmt = mysqli_stmt_init($mysqli); if (mysqli_stmt_prepare($stmt, 'call updatediscount(?,?,?,?,?,?,?,?,?,?)')) {     mysqli_stmt_bind_param($stmt, "isssssssss",        $id,        $occupation,        $last,        $first,       $email,        $phone,        $description,       $organization,       $notes,       $expiration);   mysqli_stmt_execute($stmt);   mysqli_stmt_close($stmt);   echo "success!"; } 

the update works expected except updates every single row instead of 1 row corresponding id. can't understand why happening, have where 'id'=id check. going on? how can make updates single row?

in stored procedures, when name conflict occurs between field , parameter names, parameters used.

your query parsed as:

update  ...   :id = :id 

which true (unless pass null)

prepend parameter names underscore:

create procedure myprc (_id, _occupation, ...) begin         update  mytable         set     occupation = _occupation           id = _id; end; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -