-1

I have a table called users. It has the following columns:

id

name

username

email

User can not edit any data from this table except the username column. The question is that when user wants to edit his username, what would the query be in ZF2 Tablegateway?

In my controller I have a function called getUserTable(), as created in ZF2 manual also. So I am doing something like:

$this->getUserTable()->updateUser($id, $name);

And in UserTable.php class that is in Model folder I have a function called updateUser($id, $name).

My function look like this at the moment:

public function updateUser($id, $name){

  $user_id = $id;

  $username = $name;

  $this->tableGateway->update($username, array('id' => $user_id));

}

So Basically all I want to implement is:

Update users set 'username' = $username where 'id' = $user_id

Furquan Ul Haque
  • 15
  • 1
  • 1
  • 7
  • Please don't down vote this question. If you don't want to answer or have too much pride than atleast display on the website that this web site is for experts only and not beginners, It is really demotivating to downvote someones question if it is not irrelevant. Sorry for my bad english. – Furquan Ul Haque Jun 12 '15 at 11:14
  • I don't know who downvoted or why, but usually a downvote means that someone thinks your question should be improved, and not that someone is to proud to answer your question (what a weird notion anyway). So instead of complaining about a down vote, you could think about why you received it and how you may improve your answer. And maybe, just maybe whoever gave you that downvote cares enough to come back to your question and revert the vote if you improved it. In any case you will get better answers (or answers at all) and may receive uproots from others. – mmgross Jun 12 '15 at 12:00
  • It would have been better if this website ask the person who down votes, the reason for his down votes. This isn't some Joke website where if you don't like a joke you just dislikes it. Amateurs. – Furquan Ul Haque Jun 15 '15 at 07:52

1 Answers1

1

->update (array ('username' => $username), array ('id = ?' => $id));

Sorry for formatting, I am writing on phone.

venca
  • 1,196
  • 5
  • 18