【发布时间】:2013-01-14 17:27:13
【问题描述】:
我是一名法国开发人员,很抱歉我的英语不好。
在我的网站上插入多种语言的数据时出现问题。 我说过我的 i18n 表是从控制台创建的,并以它可以工作的单一语言插入!
这是错误:
数据库错误
错误:SQLSTATE [42S22]:未找到列:1054 “字段列表”中的未知列“数组”
SQL 查询:INSERT INTO ` expandingCakePHP. Accesses(name) 值(数组)
注意:如果要自定义这个错误信息,创建app/View/Errors/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');
post 表单收到的结构是否正确? /app/Controller/AccessesController.php(第46行)
array (
'Access' => array (
'name' => array (
'eng' => 'title',
'eng' => 'title'
)
)
)
【问题讨论】:
标签: cakephp internationalization cakephp-2.0