where command sql query not working My problem is that I can't update the specific $userId. have the values I've selected. I also get an error:


  Call to a member function where() on integer 


I just started to learn Craft. It can be simple for you but not for me.

public function updateUserName($userId, $updateUser)
{

    $update = craft()-&gt;db-&gt;createCommand()-&gt;update('contest_user', array(
        'name' =&gt; $updateUser))-&gt;where('id', $userId);

    return $update;
}
When you take a look at the documentation the interface for the update function is the following.

public integer update(string $table, array $columns, mixed $conditions='', array $params=array ())


Thus your code should look like:

public function updateUserName($userId, $updateUser)
{
    $update = craft()-&gt;db-&gt;createCommand()-&gt;update(
        'contest_user', 
        array('name' =&gt; $updateUser), 
        'id=:id',
        array(':id', $userId)
    );

    return $update;
}


You can see a working example here:

// build and execute the following SQL:
// UPDATE `tbl_user` SET `name`=:name WHERE id=:id
$command-&gt;update('tbl_user', array(
    'name'=&gt;'Tester',
), 'id=:id', array(':id'=&gt;1));