cakephp删除不在模型中工作

cakephp删除不在模型中工作,php,cakephp,Php,Cakephp,由于某些原因,这不会删除??我已经调试了id,它是正确的。 有什么想法吗?我错过什么了吗? }我看不到任何提交函数。我认为应该是: class Model extends AppModel{ public function deleteSomething(){ if (empty($this->id)) { return false; } $this->read(); $db =& ConnectionManager::

由于某些原因,这不会删除??我已经调试了id,它是正确的。 有什么想法吗?我错过什么了吗?
}我看不到任何提交函数。我认为应该是:

class Model extends AppModel{

  public function deleteSomething(){

    if (empty($this->id)) {
      return false;
    }

    $this->read();

    $db =& ConnectionManager::getDataSource($this->useDbConfig);

    $db->begin($this);

    if (! $this->delete($this->id, true)) {
      $db->rollback($this);
      return false;
   }
   return $db->commit($this);
}
在控制器中创建一个删除函数。。。 然后进入index.ctp页面

public function delete()
    {
        $this->layout = 'iphone_gps';
        $this->set('title_for_layout','Iphone GPS, LLC : Companies');
        $this->Companies = $this->request->data;
        if ($this->request->is('get')) {
            throw new MethodNotAllowedException();
        }
        foreach($this->Companies as $ids){
            $this->Companie->deleteAll(array('Companie.company_id' => $ids));
        }
        $this->Session->setFlash($this->deleted);
        $this->redirect('index');
    }
echo“
”$this->Form->input('Delete',array('class'=>'youreclass','style'=>'显示:块;宽度:100px;','onclick'=>“返回确认('yourequireddata?')),array('type'=>'hidden'));
也许您有防止删除的外键?您是否尝试手动删除它?您好,您是指直接在表上运行SQL脚本时手动删除吗?如果是这样的话,那么是的,我有,它工作得很好。很抱歉,我在那里有一个,只是在我复制它时错过了它。我现在已经把它编辑成问题了。抱歉在我的应用程序中尝试了你的代码,一切正常。您需要在其他地方检查问题。我调试了delete(),它说它使用正确的id成功运行。然后我调试了commit,它返回true。但我进入DB,那一排还在那里??
public function delete()
    {
        $this->layout = 'iphone_gps';
        $this->set('title_for_layout','Iphone GPS, LLC : Companies');
        $this->Companies = $this->request->data;
        if ($this->request->is('get')) {
            throw new MethodNotAllowedException();
        }
        foreach($this->Companies as $ids){
            $this->Companie->deleteAll(array('Companie.company_id' => $ids));
        }
        $this->Session->setFlash($this->deleted);
        $this->redirect('index');
    }
echo "<br>".$this->Form->input('Delete',array('class' => 'youreclass','style' => 'display:block;width:100px;','onclick'=>"return confirm('Are you sure for delete data?')",array('type'=>'hidden')));