【问题标题】:submit form data in database using cakephp使用 cakephp 在数据库中提交表单数据
【发布时间】:2016-04-04 07:14:27
【问题描述】:

我正在使用 cakephp,我想在我的数据库中插入表单数据,但我收到以下错误:

在默认数据源中找不到模型 Post 的表帖子。

如何将我的数据保存到数据库。在 cakephp 中我们如何将数据从控制器发送到模型?

// this is my view code 

echo $this->Form->create('posts', array('action' => 'Add'));
echo $this->Form->input('title', array('label' => 'Enter your email address:'));
echo $this->Form->end('Add');


// this is my controller code

public function Add() {

    $this->request->data['posts']['title'] = $this->request->data["posts"]["title"]; 
    $this->Post->save($this->request->data);

}

【问题讨论】:

标签: php cakephp


【解决方案1】:

错误表示未创建模型“Post”。您需要创建文件 PostsTable.php 并将其放在 src/Model/Table 文件夹中。

也可以试试 CakeBook 的 CakePHP 教程。

【讨论】:

  • 这不是错误所说的。它说它缺少与该模型一起使用的数据库表。
猜你喜欢
  • 2021-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-19
  • 1970-01-01
  • 2013-12-31
  • 2017-02-23
  • 1970-01-01
相关资源
最近更新 更多