Bluz\Crud\Table::deleteOne PHP Method

deleteOne() public method

Delete item
public deleteOne ( mixed $primary ) : integer
$primary mixed
return integer
    public function deleteOne($primary)
    {
        $row = $this->getTable()->findRow($primary);
        if (!$row) {
            throw new NotFoundException("Record not found");
        }
        return $row->delete();
    }

Usage Example

示例#1
0
文件: Crud.php 项目: dezvell/skeleton
 /**
  * @param mixed $data
  * @return int|void
  */
 public function deleteOne($data)
 {
     $table = Table::getInstance();
     $tree = $table->buildTree($data['id']);
     if (!isset($tree[0]['children'])) {
         parent::deleteOne($data);
     } else {
         $allSubCategories = $this->treeToArray($tree);
         foreach ($allSubCategories as $categoryId) {
             parent::deleteOne(['id' => $categoryId]);
         }
     }
 }