doumalu9257 2015-12-15 01:35
浏览 10
已采纳

控制器变量未显示在查询生成器Laravel中

I am encountering a strange issue in Laravel.

The below is an index function in one of my controllers.

public function index($merchant_url_text)
{
    //
    $deals = DB::table('tbl_deal')
            -> join ('tbl_merchant', 'tbl_deal.merchant_id', '=', 'tbl_merchant.merchant_id')
            -> where ('merchant_url_text', $merchant_url_text) -> toSql();
    //return $merchant_url_text.$deal_id;
            dd($deals);
            //return $merchant_url_text;
}

As you can see I am passing merchant_url_text from route.

Route::get('/testroute/{merchant_url_text}', ['uses' =>'dealsVisibleController@index']);

When I am trying to debug the query by printing it, I am getting

"select * from `tbl_deal` inner join `tbl_merchant` on `tbl_deal`.`merchant_id` = `tbl_merchant`.`merchant_id` where `merchant_url_text` = ?"

This means that the query builder is not reading the $merchant_url_text variable. However, when I return just that variable, it is being printed.

Just can't figure out why the query builder is not able to include the $merchant_url_text variable in the query when it is available in the index function.

Any suggestions.

  • 写回答

2条回答 默认 最新

  • doqrjrc95405 2015-12-15 03:46
    关注

    I am pretty sure that your code is correct. The SQL output function toSql() does not show the values of variables and only prints out a ? for security reasons.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题