未在cakephp中插入到我的表中的值
app/controller/CarrierController.php 这里我插入到数据库表中,但未插入,显示无法添加您的详细信息 数据库表字段id(自动递增)、fname、lname、dob、字段、性别未在cakephp中插入到我的表中的值,cakephp,Cakephp,app/controller/CarrierController.php 这里我插入到数据库表中,但未插入,显示无法添加您的详细信息 数据库表字段id(自动递增)、fname、lname、dob、字段、性别 class CarrierController extends AppController { public $helpers = array('Html', 'Form', 'Session'); public $components = array('Session');
class CarrierController extends AppController {
public $helpers = array('Html', 'Form', 'Session');
public $components = array('Session');
var $uses=array('Carrier');
public function index(){
// $this->set('posts', $this->carrier->find('all'));
if($this->request->is('post')){
Configure::read();
pr($this->data);
$this->Carrier->create();
if ($this->Carrier->save($this->request->data)) {
$this->Session->setFlash(__('Your Details has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('Unable to add your Details'));
}
}
}
}
app/view/Carrier/index.ctp
<h1>welcome to Carriers</h1>
<br />
<br/>
<?php echo $this->Form->create('Carriers', array('enctype' => 'multipart/form-data'));?>
<table>
<tr><h3>Register here</h3></tr>
<tr><td>F.Name</td><td><?php echo $this->Form->text('fname'); ?></td></tr>
<tr><td>L.Name</td><td><?php echo $this->Form->text('lname');?></td></tr>
<tr><td>Date Of Birth</td><td><?php echo $this->Form->date('dob');?></td></tr>
<tr><td>Degree</td><td><?php echo $this->Form->select('field', array('options' => array('B.E','B.sc','Mca','Mtech','Mba'),'empty' => '(choose)')); ?></td></tr>
<tr><td>Sex</td><td><?php
$options=array('M'=>'Male','F'=>'Female');
$attributes=array('legend'=>false);
echo $this->Form->radio('gender',$options,$attributes);
?></td></tr>
<tr><td><?php echo $this->Form->input('Carriers.Resume', array('between'=>'<br />','type'=>'file'));?></td></tr>
<tr><td><?php echo $this->Form->end('Apply');?></td></tr>
</table>
欢迎来到运营商
在这里注册
F.姓名
L.姓名
出生日期
度
性别
app/model/Carrier.php
<?php
class Carrier extends AppModel{
public $useTable='carrier'; //this is table name fields are inserted
}
?>
in-form Carrier必须是单数:form->create('Carrier')等等……如果我记得你,你又犯了同样的错误,表名应该是复数,在你的情况下是carriers。我肯定你昨天问了这个问题。对于您的问题,您正在尝试将文件保存到db,这会导致错误。在进行如此多的开发之前,您需要阅读更多的文档。