消息:未定义的索引:id

时间:2014-12-23 09:01:33

标签: php idiorm

我的查询

$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

1 个答案:

答案 0 :(得分:2)

根据您的var转储$proveedores是一个包含2个元素的数组,表示表中的2行。 您发出的查询似乎返回了2行作为访问它们的结果,您应该执行类似以下的操作

$id1 = $proveedores[0]['id'];
$id2 = $proveedores[1]['id'];
相关问题