简体   繁体   中英

Laravel - update row with variable using fluent query builder

iam building my web app, and i need to the simplest thing, just update fields inside table with some variables,but its not working he doesnt do anything ,values of the fields remain just as it was.

public function post_eupdate(){

  $update = DB::table('app_events')
      ->where('ev_id', '=', Input::get("id"))
      ->update(
          array(
             'ev_op1'    =>  Input::get('op1'),
             'ev_op2'    => Input::get('op2'),
             'ev_coef1'  => Input::get('coef1'),
             'ev_coef2'  => Input::get('coef2'),
             'ev_host'   => Input::get('host'),
             'ev_stime'  => Input::get('stime'),
             'ev_ns1'    => Input::get('ns1'),
             'ev_cat'    => Input::get('cat'),
             'ev_tip'    => Input::get('tip'),
             'ev_ns2'    => Input::get('ns2')
         )
     );

Your update statements seams good.

My guess would be that the problem is that Input::get("id") isn't a valid id for app_events.ev_id

Try debugging this by replacing ->update with ->get(). If this return null you would know that my assumption is correct. (If not post it in you question.)

As this is the case you have to modify the Input and not this piece of code which makes your question no longer fitting for the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM