敏捷工具包CRUD在本地主机上完美运行,在服务器上引发错误 [英] Agile Toolkit CRUD works perfectly on localhost throws error on server
问题描述
我需要ATK4 CRUD方面的帮助.我已经使用Agile Toolkit 4.1.3为项目构建了一个后端. 我有以下模型:
I need help in ATK4 CRUD. I have built a backend for a project using Agile Toolkit 4.1.3. I have the following Model:
class Model_Product extends Model_Table
{
public $entity_code = 'product';
function init()
{
parent::init();
$this->addField('category_id')->refModel('Model_Category')->mandatory(true);
$this->addField('name')->mandatory(true);
$this->addField('picture_id')->refModel('Model_Picture')->mandatory(true);
$this->addField('short_description')->mandatory(true);
$this->addField('description')->type('text')->mandatory(true);
$this->addField('uploaded_at')->type('datetime');
$this->addField('price')->type('int')->mandatory(true);
$this->addField('quantity')->type('int')->mandatory(true);
$this->addField('status')->datatype('list')
->listData(array(
'enabled'=>'Enabled',
'disabled'=>'Disabled',
))
->defaultValue('enabled');
}
}
页面:
<?php
class page_index extends Page {
function init(){
parent::init();
$page=$this;
$tabs = $page->add('Tabs');
$tabs->addTab('Product')->add('CRUD')->setModel('Product');
....
在我的本地主机上,所有CRUD功能都可以正常工作,但是当我尝试添加新产品时将文件上传到网络服务器后,出现此错误:
On my localhost all CRUD functions work flawlessly, but after I uploaded the files to the webserver when I try to add a new product I get this error:
`AJAX响应错误:SyntaxError:无效的XML属性值 SQLException
`Error in AJAX response: SyntaxError: invalid XML attribute value SQLException
无法执行查询:插入产品(category_id
,name
,picture_id
,short_description
,description
,uploaded_at
,price
,quantity
,status
)的值( NULL,'as',NULL,'','',NULL,2500,25,'已启用')
最后查询:
插入产品值(category_id
,name
,picture_id
,short_description
,description
,uploaded_at
,price
,quantity
,status
)值(NULL,'as',NULL, '',``,NULL,2500、25,'已启用')
MySQL错误:
列"category_id"不能为空`
Could not execute query: insert into product (category_id
, name
, picture_id
, short_description
, description
, uploaded_at
, price
, quantity
, status
) values (NULL, 'as', NULL, '', '', NULL, 2500, 25, 'enabled')
Last query:
insert into product (category_id
, name
, picture_id
, short_description
, description
, uploaded_at
, price
, quantity
, status
) values (NULL, 'as', NULL, '', '', NULL, 2500, 25, 'enabled')
MySQL error:
Column 'category_id' cannot be null`
奇怪的是,查询中的缺失值以粗体形式可见,但从未出现在查询中.附加信息:在Model_Picture中,我使用varchar id字段而不是autoincrement int,但再次在localhost上一切正常.
Strange thing that the missing values in the query are visible in the crud form but never make it to the query. Additional info: in Model_Picture I use varchar id field instead of autoincrement int but once again everything works fine on localhost.
谢谢!
推荐答案
我在选项卡上的所有页面上都使用了我所有的crud函数,如下所示:
I had all my crud functions on one page on tabs like this:
<?php
class page_index extends Page {
function init(){
parent::init();
$page=$this;
$tabs = $page->add('Tabs');
$tabs->addTab('Product')->add('CRUD')->setModel('Product');
$tabs->addTab('Category')->add('CRUD')->setModel('Category');
$tabs->addTab('Property')->add('CRUD')->setModel('Property');
$tabs->addTab('Property <> Product')->add('CRUD')->setModel('ProductProperty');
$tabs->addTab('Payment options')->add('CRUD')->setModel('Payment');
$tabs->addTab('Shipping options')->add('CRUD')->setModel('Shipping');
$tabs->addTab('Users')->add('CRUD')->setModel('User');
$tabs->addTab('Email addresses')->add('CRUD')->setModel('Email');
$tabs->addTab('News')->add('CRUD')->setModel('News');
$tabs->addTab('Downloads')->add('CRUD')->setModel('Download');
$tabs->addTab('Designer Aids')->add('CRUD')->setModel('Aid');
}
}
然后我为每个模型创建一个新页面,并在每个页面上仅添加一个CRUD,它解决了该问题,现在在localhost和服务器上都可以正常工作.
Then I created a new page for every Model and added only one CRUD on each page and it solved the problem, now it works fine both on localhost and the server.
谢谢大家的帮助.
这篇关于敏捷工具包CRUD在本地主机上完美运行,在服务器上引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!