or-6ren">
gpt4 book ai didi

php - 消息 : Undefined index: id

转载 作者:搜寻专家 更新时间:2023-10-31 21:08:31 25 4
gpt4 key购买 nike

我有问题

$proveedores = ORM::for_table('proveedor')->where_like('nombreproveedor',"%{$namesearch}%")->order_by_asc('nieproveedor')->find_many();

我想保存id。我意识到:

$_SESSION['idproveedor'] = $proveedores['id'];

我的表结构是:

enter image description here

I get the following error in slim

Type: ErrorException
Code: 8
Message: Undefined index: id

错误得到它

$_SESSION['idproveedor']=$proveedores['id'];

var_dump($proveedores);die() 输出为:

array (size=2)
0 =>
array (size=9)
'id' => string '1' (length=1)
'nieproveedor' => string '11111111' (length=8)
'nombreproveedor' => string 'Agrar Semillas S.A' (length=18)
'direccion' => string 'Route de Saint Sever
' (length=23)
'telefono' => string ' 976470646' (length=10)
'ciudad' => string '' (length=0)
'region' => null
'pais' => null
'codpostal' => null
1 =>
array (size=9)
'id' => string '2' (length=1)
'nieproveedor' => string '22222222' (length=8)
'nombreproveedor' => string 'Agrosa Semillas Selectas, S.A.' (length=30)
'direccion' => string 'ddddsfwwffwwwwwwffwfw' (length=21)
'telefono' => string ' 949 305226' (length=11)
'ciudad' => string '' (length=0)
'region' => null
'pais' => null
'codpostal' => null

最佳答案

根据您的 var dump $proveedores 是一个包含 2 个元素的数组,代表您表中的 2 行。您发出的查询似乎返回了 2 行,因此要访问它们,您应该执行如下操作

$id1 = $proveedores[0]['id'];
$id2 = $proveedores[1]['id'];

关于php - 消息 : Undefined index: id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27617071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com