0

我是一名法国开发人员,很抱歉我的英语不好。

在我的网站上插入多种语言的数据时出现问题。我说我的 i18n 表是从控制台创建的,并以它可以工作的单一语言插入!

这是错误:

数据库错误

错误:SQLSTATE [42S22]: Column not found: 1054 Unknown column 'Array' in 'field list' SQL Query: INSERT INTO ` expandingCakePHP. Accesses( name) VALUES (Array) 注意:如果要自定义此错误消息,请创建应用程序/视图/错误/pdo_error.ctp

我的 admin_add.ctp(文件查看/访问)

foreach (Configure :: read ('Config.languages​​') as $lang) {
echo $this-> Form-> input ('Access.name.'. $lang, array ('label' => __ ('Name'). '(. $lang.') '));
}

我的 access.php(模型文件)

var $actsAs = array (
   'Translate' => array (
      'name' => '_name'
   )
);

我的 AccessesController.php(控制器文件夹)

admin_add public function () {
   if ($this-> request-> is ('post')) {
      $this-> Access-> create ();
      $this-> Access-> locale = Configure :: read ('Config.languages​​');
      if ($this-> Access-> save ($ this-> request-> data)) {
         $this-> Session-> setFlash (__ ('The access has been saved'), 'notif');
         $this-> redirect (array ('action' => 'index'));
      }
      else {
         $this-> Session-> setFlash (__ ('The Access Could not be saved. Please, try again.'), 'notif', array ('type' => 'alert-error'));
      }
   }
}

在我的 bootstrap.php (配置文件)

Configure :: write ('Config.languages​​', array ('eng', 'eng'));
Configure :: write ('Config.language', 'eng');
Configure :: write ('App.encoding', 'utf-8');

邮寄表格收到的结构是否正确?/app/Controller/AccessesController.php(第46行)

array (
   'Access' => array (
      'name' => array (
         'eng' => 'title',
         'eng' => 'title'
      )
   )
)
4

3 回答 3

1

用这个

 $this->Model->save($this->request->data,false);
于 2015-05-25T01:20:22.897 回答
0

请用$this->Model->saveAll($this->request->data);

代替$this->Model->save($this->request->data);

于 2014-07-06T09:33:30.173 回答
0

帖子结构似乎错误,例如参见http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveassociated-array-data-null-array-options-array

它应该更像:

array (
   'Access' => array (
      'name' => 'a name',
      'title' => 'a title',
      'another model' => array(...)
      )
   )
)
于 2013-01-16T18:52:12.897 回答