【问题标题】:Phalcon insert new dataPhalcon插入新数据
【发布时间】:2023-03-23 05:35:02
【问题描述】:

我有以下代码:

控制器

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;
            }
        }
    }
}

型号

use Phalcon\Mvc\Model;

class Data extends Model{

   public $id;

   public $text;

   public function getSource() {

       return 'data';
   }
}

在我的本地环境中,它工作正常,但是当我将它上传到 AWS 并对其进行调试时,代码 query->text = "test";没有执行它在它之前中断。我检查了该表是否存在。您能帮我了解问题出在哪里吗?

【问题讨论】:

  • 您看到了什么错误信息?怎么破?

标签: php phalcon


【解决方案1】:

尝试替换

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

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

带$符号

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-07
    • 2023-03-17
    • 2014-10-25
    • 2021-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多