其中uuid的条件在laravel中不起作用

发布于 2025-02-07 18:05:30 字数 649 浏览 2 评论 0原文

我的其中()使用UUID的条件在Laravel中对我不起作用。

public function skills($id)
{
    $skills = DB::table("industry_skill_sets")
        ->whereIn('industry_id', [$id])
        ->pluck("name", "id");
    
    print_r($skills);
    
    exit;
}

在这里,我的身份证是由逗号隔开的UUID。因此,当我回应ID时,我会得到以下内容。

2b5e5507-7e01-45fe-b0ed-331135479061,7c816e0f-d6e2-489c-bdce-df064b3e99f9

当我在其中的条件下使用此变量时,它会显示错误。

sqlstate [22P02]:无效文本表示:7错误:无效输入 类型UUID的语法: “ 2B5E5507-7E01-45FE-B0ED-331135479061,7C816E0F-D6E2-D6E2-489C-BDCE-DFCE-DF064B3E99F9”

我正在使用PostgreSQL作为数据库。

My whereIn() condition using a UUID is not working for me in Laravel.

public function skills($id)
{
    $skills = DB::table("industry_skill_sets")
        ->whereIn('industry_id', [$id])
        ->pluck("name", "id");
    
    print_r($skills);
    
    exit;
}

Here my id is the UUID separated by commas. So when I echo id, I am getting the following.

2b5e5507-7e01-45fe-b0ed-331135479061,7c816e0f-d6e2-489c-bdce-df064b3e99f9

When I use this variable in the WhereIn condition, It shows an error.

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input
syntax for type uuid:
"2b5e5507-7e01-45fe-b0ed-331135479061,7c816e0f-d6e2-489c-bdce-df064b3e99f9"

I am using PostgreSQL as a database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟火散人牵绊 2025-02-14 18:05:31

需要将UUID转换为字符串

$skills = DB::table("industry_skill_sets")
                    ->whereIn('industry_id', explode(',',$id))
                    ->pluck("name","id");

Need's to convert UUID to string

$skills = DB::table("industry_skill_sets")
                    ->whereIn('industry_id', explode(',',$id))
                    ->pluck("name","id");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文