ai didi

php - 如何获取PHP查询的返回值

转载 作者:行者123 更新时间:2023-11-29 17:33:12 24 4
gpt4 key购买 nike

所以我在下面有这个查询,我想从数据库的表中获取id:

$getId = DB::Select("select group_id from sm_group where group_name = '.$search.'" );
var_dump("returned ", $getId);

但这只会返回:

string(9) "returned " array(0) {} No properties

我想要的是id,它是一个整数。我能做到吗?

最佳答案

您可以使用它来获取单个列:

$id = DB::table('sm_group')->where('group_name', $search)->value('group_id');

但是,由于您的查询未返回任何行,因此似乎未找到匹配项。

关于php - 如何获取PHP查询的返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50478699/

24 4 0
文章推荐: android - 为什么我不能在 productFlavors 中使用 packageName?
文章推荐: asp.net - 如何从javascript更改缓存的图片
文章推荐: javascript - jquery 可排序/可选 : filtering child controls
文章推荐: PHP MySQL 更新仅用循环更新最后一行
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com