duanan1946 2014-06-12 05:06
浏览 274

Laravel mysql_query错误异常

I'm trying to move to laravel, and my old app still uses mysql_query. Is it possible to bypass the following error i'm getting in laravel?

ErrorException

mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

Please let me know - rewriting all SQL queries is not an option right now. Maybe in the future, but right now, I want to get up and running.

Also, I'm using a DB class to run the queries through mysql, is there a better way to move to PDO vs rewriting every single SELECT, UPDATE, DELETE, and CREATE query?

Thanks!

  • 写回答

1条回答 默认 最新

  • dongqing4774 2014-06-12 08:41
    关注

    If you are using mysql_query() it means that you are using raw queries to execute your logic. You can use laravel's raw queries to execute.

    http://laravel.com/docs/database#running-queries

    However, there is a down side for the CRUD queries you'll still have to do a bit of customization for example running an insert statement would be like this.

    DB::insert('insert into users (id, name) values (?, ?)', array(1, 'Dayle'));

    Plus side will be it will automatically sanitize the input so you don't have to worry about sql injections etc. I don't think there is a more quicker way of doing this in laravel.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!