-1
您好我有一个为具有一个场(网址),我想在表单中键入的URL插入到数据库如何将数据插入到数据库中的CakePHP
我的函数添加在我的控制器看起来像这个:
public function add(){
if($this->request->is('post')){
// debug($this->Link->find('all'));//this works
$link = $this->Link->findByUrl($this->request->data['link']['url']);
if(empty($link)){
//I will create the link
$this->Link->create($this->request->data, true);//true = ignoring the ID
$this->Link->save(null, true, array('url'));
//null = because I ready wrote "$this->request->data" in create
//true = I want to use VALIDATION
//array = I choose to SAVE this field only
echo "I've created the link";
die($this->Link->id);
}else {
debug($link);
die("The link is already in the database");
//je dois récupérer le lien
}
}
如何在数据库中插入输入的链接?