public function consultar_existencia($campo) {
if ($this->request->is('post')) {
$this->autoRender = false;
$this->layout = false;
$this->loadModel('Client');
$existe = $this->Client->find('count', array(
'conditions' => array($campo => $this->request->data('Field')['Data'])));
}
echo json_encode($existe);
}
Hi, I have this function in the controller, I'm going to use it to validate if a data already exists in the DB, the idea is to make some changes, but ps I had some problems I'm going to show you:
public function consultar_existencia($campo)
// field is for the field that is going to be compared in the database, and the idea would also be to send you the model you are going to consult by adding something like $model
in the parameters, and in this line it is It would load like this: $this->loadModel($model);
, and there I think we would go bn, the problem comes in this line:
$existe = $this->Client->find('count', array(
'conditions' => array($campo => $this->request->data('Field')['Data'])));
since in that line a call is made to a specific model, and my question is, is there any way of telling you to check the model currently loaded? something like
$this->getLoadModel()->find('count', array(
'conditions' => array($campo => $this->request->data('Field')['Data'])));