Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

NOTIFICATION ON THE API NOT WORKING

I made the edit password based on uid and account is value 1, then i check the results show "Updated" and the data in the database i check also successfully updated, but when i check in the column of account is value 0, the data in the database was not successfully updated, but the notification shows "Updated",it's should be "ERROR"

> $phql = "UPDATE Users SET password=:password: WHERE uid=:uid: AND account=:account:";

    $status = $app->modelsManager->executeQuery(
        $phql,
        [
            'uid'           => $uid,
            'password'  => md5($_POST['password']),
            'account' => '1'
        ]
    );

> $response = new Response();

   if (count($status) > 0) {

            $response->setJsonContent(
                array(
                    'status' => 'Updated'
                )
            );
   } else {

        $response->setJsonContent(
                array(
                    'status' => 'ERROR'
                )
            );
    }
return $response;

}



1.4k
Accepted
answer
edited Sep '17

First off, don't use MD5 to hash passwords. use password_hash()

Second, SQL always returns a status containing the amout of row effected by a command. so your count will always equal 1.

you should be using $status->rows_effected > 0 I think

edited Sep '17

if use passwordhash(), it's result not change of password in the database and for $status->rowseffected > 0 it result is error

edited Sep '17

>if use passwordhash(), it's result not change of password in the database >and for $status->rowseffected > 0 it result is error

Then you should maybe try execute the command manually. see if you get errors. If not, dump what you get back from the database in phalcon.

OK, Thank you very much for helping me..