PHP PDO Prepared statement query not updating record -


I'm having trouble using PHP's PDO object to prepare an update statement and update the record. The raw SQL query has been taken and it has been taken in phpMyAdmin with the parameters replaced by their values, which have been passed in the function. Which updates as intended in the form of records, however, it is not updated when running from script. It throws zero errors and gives an error of 00000 (info) returns, which I think is the best way to say PDO. I know that the PDO object works because it successfully incorporates the database and selects the record, in which I am trying to update. I understand that this update function is ugly, I just do PDF

Obviously, this is coded in PHP5, using PDO

Learning class function: ..

  public function update ($ tbl_name, $ where = null, $ what = null) {if_array ($ where)) {$ where_str = 'where'; Foreign currency ($ where $ key => $ val) {$ where_str. = "{$ Key} = ': {$ key}' and ';} $ Where_str = substr ($ where_str, 0, -5); $ what_str =' set '; foreign currency ($ what $ key => $ Val) {$ what_str. = "` {$ Key} `= ': {$ key}', '; } $ What_str = substr ($ what_str, 0, -2); $ Query_str = "Update {$ tbl_name} {$ what_str} {$ where_str} LIMIT 1;"; $ Stmt = $ this- & gt; Dbh- & gt; Ready ($ query_str); Echo '& lt; Pre & gt; Print_r ($ stmt, true) '& Lt; / Pre & gt; '; Forex currency ($ $ $ key => $ val) {if ('date_time' === $ key) is in progress; $ Dam = $ stmt-> Bind Value (": {$ key}", $ val); Echo ($ bind? 'True': 'wrong'). ": {$ Key} =", $ val, '& lt; Br / & gt; '; } Forex ($ where $ key => $ val) {If ('date_time' === $ key) is in progress; $ Dam = $ stmt-> Bind Value (": {$ key}", $ val); Echo ($ Tie? 'True': 'False'). ": {$ Key}", $ val, '& lt; Br / & gt; '; }} And {return false; } $ This- & gt; Dbh- & gt; Set Attribution (PDO :: ATTRMROM, PDO :: ERMMDMEXEPEPS); $ Exec = $ stmt-> carry about (); 'Exec:' ($ exec === true? 'True:': 'wrong:'). ':'. $ Exec '& Lt; Br / & gt; '; Echo '& lt; Pre & gt; '; $ Stmt- & gt; DebugDumpParams (); Echo & lt; / Pre & gt; '; Return $ stmt-> gt; ErrorInfo (); Called from session update / login script:  
  $ where = array ('id' = & gt; $ user ['id']  

],); $ What = array ('twitter_key' = & gt; $ oauth_token, 'twitter_secret' => $ oauth_token_secret); $ Update = $ db- & gt; Update ('user', $ where, $ what);

Output from print_r and caller in echo and class function:

  // print_r ($ stmt = $ this-> dbh- & ($ Query_str) output: PDOStatement object ([query string] => update users set `twitter_key` = ': twitter_key',` twitter_secret` = ': twitter_secret' where id = ': id' border 1 ;) // Production Bing parameter and execution return true: twitter_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXX true: twitter_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX true: ID 20 executive: true: 1 // $ stmt-> DebugDumpParams () Production: SQL: [111] Update users set `twitter_key` = ': Twitter_key',` twitter_secret` = ': twitter_secret' where id = ': id' border1; Parameter: 3 Key: Name: [12]: twitter_key paramno = -1 name = [12] ": twitter_key" is_param = 1 = 2 param_type key: Name: [15]: twitter_secret paramno = -1 name = [15] " : Twitter_secret "is_param = 1 param_type key: name: [3]: id paramno = -1 name = [3]": id "is_param = 1 = 2 param_type // print_r ($ stmt-> errorInfo () ) Output: Array ([0] => 00000)  

I do not know There is a lot about PDO, but I think there is something wrong with the way to force the parameters. However, the easiest way to make sure is to look at the actual query. According to

, you should be able to see the generated query because it $ stmt-> query string . It is not possible to see it right now because you after that you are outputting $ stmt

() (Or maybe even after query execution, I do not know) Tie. You should get a real query string, and go to the bottom of the problem.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -