thanks see I have this problem I want to check if my id (of my user), exist into a other table if this not exist redirect to my add.
table1
| users |
| id |
| username |
| password |
| creation |
| type |
table2
| user_azucar |
| id |
| id_user |
| cant |
| medaza |
| cachaza |
I don't want to use hasone because is not for this case.
I want compare id==id_user exist a session for this. controller
class IngeniosController extends AppController
{
public function add()
{
}
public function index()
{
$this->loadModel('Ingenio');
$conditions = array(
'conditions' => array(
'UserAzucar.id_user' => $this->Session->read('User.id')
)
);
$result = $this->User->find('first', $conditions);
if (isset($result['User'])){
$this->redirect(array('action' => 'add'));
}
}
public function delete()
{
}
}
model
<?php
/**
*
*/
class Ingenio extends AppModel
{
public $name = 'UserAzucar';
public $useTable = 'usuarios_azucar';
public $primaryKey = 'id_azucarusuario';
}
?>