src/Data/BizDataObj.php
public function deleteRecord($recArr)
    {
        $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr));
        if (!$this->canDeleteRecord()) {
            $this->errorMessage = MessageHelper::getMessage("DATA_NO_PERMISSION_DELETE", $this->objectName);
            throw new Openbizx\Data\Exception($this->errorMessage);
            return false;
        }

        if ($recArr) {
            $delrec = $recArr;
        } else {
            $delrec = $this->getActiveRecord();
        }

        $this->bizRecord->setInputRecord($delrec);

        $sql = $this->getSQLHelper()->buildDeleteSQL($this);
        if ($sql) {
            $db = $this->getDBConnection("WRITE");
            $db->beginTransaction();
            try {
                $this->cascadeDelete(); // cascade delete
                Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Delete Sql = $sql");
                $db->query($sql);
                $db->commit();
                $this->bizRecord->saveOldRecord($delrec); // save old record only if delete success
            } catch (Exception $e) {
                $db->rollBack();
                if ($e instanceof Openbizx\Data\Exception)
                    throw $e;
                else {
                    Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query error : " . $e->getMessage());
                    $this->errorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage();
                    throw new Openbizx\Data\Exception($this->errorMessage);
                }
                return false;
            }
        }

        //clean cached data
        $this->cleanCache();

        $this->_postDeleteRecord($this->bizRecord->getKeyValue());
        $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr));
        return true;
    }
public function deleteRecord($recArr)
    {
        $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr));
        if (!$this->canDeleteRecord()) {
            $this->errorMessage = MessageHelper::getMessage("DATA_NO_PERMISSION_DELETE", $this->objectName);
            throw new Openbizx\Data\Exception($this->errorMessage);
            return false;
        }

        if ($recArr) {
            $delrec = $recArr;
        } else {
            $delrec = $this->getActiveRecord();
        }

        $this->bizRecord->setInputRecord($delrec);

        $sql = $this->getSQLHelper()->buildDeleteSQL($this);
        if ($sql) {
            $db = $this->getDBConnection("WRITE");
            $db->beginTransaction();
            try {
                $this->cascadeDelete(); // cascade delete
                Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Delete Sql = $sql");
                $db->query($sql);
                $db->commit();
                $this->bizRecord->saveOldRecord($delrec); // save old record only if delete success
            } catch (Exception $e) {
                $db->rollBack();
                if ($e instanceof Openbizx\Data\Exception)
                    throw $e;
                else {
                    Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query error : " . $e->getMessage());
                    $this->errorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage();
                    throw new Openbizx\Data\Exception($this->errorMessage);
                }
                return false;
            }
        }

        //clean cached data
        $this->cleanCache();

        $this->_postDeleteRecord($this->bizRecord->getKeyValue());
        $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr));
        return true;
    }
Delete current record or delete the given input record

@param array $recArr - associated array whose keys are field names of this BizDataObj
@return boolean - if return false, the caller can call GetErrorMessage to get the error.