W
W
wolf-98302016-05-10 21:55:38
CakePHP
wolf-9830, 2016-05-10 21:55:38

How to work with two tables?

My goal is to first check if there is a value in one table, then write the data to another table, I do this:

$this->Cabinet->useTable = 'accounts';
      $subjectInfo = $this->Cabinet->find('all',[
          'conditions' => [
            'temp_login' => $subject
          ]
        ]);
      if(!$subjectInfo)
        return 0;

$this->Cabinet->useTable = 'messages';
      $this->Cabinet->create();
      $this->Cabinet->set([
          'userIdFrom' => 0,
          'loginFrom' => $tempLogin,
          'loginTo' => $subject,
          'message' => $message,
          'deleteAfterRead' => $deleteAfterRead
        ]);
      $this->Cabinet->save();

But it does not work, how to be?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question