order_b...">

Message: Undefined index: id

I requested

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

      

I want to store the id. I understand:

$ _ SESSION ['idproveedor'] = $ proofedores ['id'];

My table structure:

enter image description here

I get the following error in slim

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

      

the error will turn out in

$ _ SESSION ['idproveedor'] = $ proveedores ['ID'];

var_dump ($ proofedores); die () output:

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

      

+3


source to share


1 answer


According to your var dump, $proveedores

there is an array with 2 elements that represent 2 rows in your table. The query you issued seems to have returned 2 rows, to access them you should do something like the following



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

      

+2


source







All Articles