Abdizriel
Abdizriel

Reputation: 355

Phalcon insert new data

I've got following code:

Controller

class UploadController extends ControllerBase{

    public function indexAction() {

        if ($this->request->isPost()){

            query = new Data();
            query->text = "test";

            if ($query->save() == false) {
                echo "Umh, We can't store data right now: \n";
                foreach ($query->getMessages() as $message) {
                    echo $message, "\n";
                }
            } else {
                $id = $query->id;
            }
        }
    }
}

Model

use Phalcon\Mvc\Model;

class Data extends Model{

   public $id;

   public $text;

   public function getSource() {

       return 'data';
   }
}

On my local environment it is working correctly, hovewer when I uploaded it to AWS and debugged it code query->text = "test"; is not executed it breaks before it. I checked that table exist. Could you help me understand where the problem exist?

Upvotes: 0

Views: 738

Answers (1)

IGeorg
IGeorg

Reputation: 46

Try replace

query = new Data();
query->text = "test";

to

$query = new Data();
$query->text = "test";

with $ sign

Upvotes: 1

Related Questions