dongtao5055 2014-10-31 12:02
浏览 369

如何在laravel中使用sql NOW()函数

I have used sql's now() function several times in normal query in php db connectivity...

But in laravel it does not displays anything and also the data is not inserted

the code I am using is:

$exercise = Exercise::insert(
                    array(  'fk_users_id'       => '1',
                            'fk_equipments_id'  => $equipment,
                            'muscular_group'    => $muscular,
                            'exercise_name'     => $postedContent['exercise_name'],
                            'exercise_type'     => $postedContent['type'],
                            'Status'            => '1',
                            'DateCreated'       => 'NOW( )',
                            'DateModified'      => 'NOW( )')
                    );  

it stores the data into the database but the time in not stored in any of the columns

at first my method was:

$exerciseDetails    = Input::all();         
$exercise           = Exercise::create($exerciseDetails);  

the above method updates date and time itself and worked fine for other controllers but now I am having a problem of having a check box checked array in my post so it throws error

is there any other method in laravel to do this ??

  • 写回答

3条回答 默认 最新

  • douhuzhi0907 2014-10-31 12:12
    关注

    Laravel comes with created_at and updated_at timestamp fields by default, which it keeps updated by itself.

    http://laravel.com/docs/4.2/eloquent#timestamps

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化