⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Column not found: 1054 Unknown column in where clause



ajuser
  • profile picture
  • Member

Posted 12 February 2020 - 07:57 AM

Good, I am trying to make a simple relationship between two tables, but when I put the where clause, it shows that it does not find the idcentro column.
I detail the controller code and the image of the tables.
In the community version it works without problems.
 
 
<p>Type: PDOException</p>
<p>Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'idcentro' in 'where clause'</p>
<p>Filename: /var/www/vhosts/control.instalnox.com/httpdocs/application/libraries/GroceryCrudEnterprise/zendframework/zend-db/src/Adapter/Driver/Pdo/Connection.php</p>
<p>Line Number: 360</p>

 

 

function list_contrato() {

      $crud = $this->_getGroceryCrudEnterprise();  
      $center = $this->session->userdata('idcentro');
      $crud->settable('contrato');
      $crud->setsubject('Contratos');
      $crud->columns(['idpersona','descripcion','fechadesde','fechahasta','numerohora'])
        ->displayas('idpersona','Trabajador')
        ->displayas('descripcion','Descripción')
        ->displayas('fechadesde','Desde fecha')
        ->displayas('fechahasta','Hasta fecha')
        ->displayas('numerohora','Horas semanales');
      $crud->requiredfields(['idpersona','descripcion','fechadesde','numerohora']);
   //   $crud->setrules('fechahasta', 'Hasta', 'callback_valid_date');
 $crud->setrelation('idpersona','persona','{apellido}, {nombre}',['idcentro'=>$center]);
 $crud->where(['idcentro'=>$center]); 
      $output = $crud->render();
 $this->_main_output($output);
}

 


larasmith
  • profile picture
  • Member

Posted 04 March 2020 - 06:29 AM

Hi ajuser,

 

Try adding: $crud->setPrimaryKey('idcentro','persona'); before $crud->setrelation('idpersona','persona','{apellido}, {nombre}',['idcentro'=>$center]);

I hope this helps!  :)