插入查询在php中不起作用
这是操作url:插入查询在php中不起作用,php,cakephp,cakephp-1.3,Php,Cakephp,Cakephp 1.3,这是操作url:http://localhost/carsdirectory/users/dashboard dashboad.ctp(我有一个select字段,在这个select字段中,我从该字段的car\u类型和表名car\u类型中获取数据) car.php(模型) 我想在(表名cars)中插入数据car\u type\u id字段,但我无法这样做 所以请帮帮我 提前感谢,vikas tyagi您可以尝试以下方法: echo $this->Form->input('Car.c
http://localhost/carsdirectory/users/dashboard
dashboad.ctp(我有一个select字段,在这个select字段中,我从该字段的car\u类型和表名car\u类型中获取数据)
car.php(模型)
我想在(表名cars)中插入数据car\u type\u id字段,但我无法这样做
所以请帮帮我
提前感谢,vikas tyagi您可以尝试以下方法:
echo $this->Form->input('Car.car_type_id', array(...));
什么是错误?它将转到
其他
?感谢您的回复,我已经做了公开,但车型id文件中仍然为空值。我没有收到任何错误,但车型id文件中为空值。您的表单返回数据[用户][车型]
,您正在尝试保存到车型中。保罗先生,我该怎么办,你能再解释一下吗。
class UsersController extends AppController{
var $name = "Users";
public function dashboard(){
$this->loadModel('Car_type'); // your Model name => Car_type
$this->set('car_types', $this->Car_type->find('all'));
if(!empty($this->data))
{
$this->loadModel('Car');
if($this->Car->save($this->data))
{
$this->Session->setFlash('Detail has Been Saved');
$this->redirect(array('action'=>'dashboard'));
}
else
{
$this->Session->setFlash('Detail could not save');
}
}
}
<?php
class Car extends appModel{
var $name = "Car";
}
?>
echo $this->Form->input('Car.car_type_id', array(...));