Reputation: 193
I´ve my query
$proveedores = ORM::for_table('proveedor')->where_like('nombreproveedor',"%{$namesearch}%")->order_by_asc('nieproveedor')->find_many();
I want to save the id. I realize:
$_SESSION['idproveedor'] = $proveedores['id'];
My table structure is:
I get the following error in slim
Type: ErrorException
Code: 8
Message: Undefined index: id
the error get it in
$_SESSION['idproveedor']=$proveedores['id'];
var_dump($proveedores);die() output is:
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
Upvotes: 3
Views: 2331
Reputation: 12504
According to your var dump $proveedores
is an array with 2 elements which represent 2 rows in your table.
The query that you issued seems to have returned 2 rows as a result to access them you should do something like the following
$id1 = $proveedores[0]['id'];
$id2 = $proveedores[1]['id'];
Upvotes: 2