src/Data/BizDataObj.php
public function insertRecord($recArr)
    {
        $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr));
        if ($this->_isNeedGenerateId($recArr))
            $recArr["Id"] = $this->generateId();    // for certain cases, id is generated before insert

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

        if (!$this->validateInput())
            return false;

        $db = $this->getDBConnection("WRITE");

        try {
            $sql = $this->getSQLHelper()->buildInsertSQL($this, $joinValues);
            if ($sql) {
                Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Insert Sql = $sql");
                $db->query($sql, $bindValues);
            }
            //$mainId = $db->lastInsertId();
            if ($this->_isNeedGenerateId($recArr)) {
                $this->m_db = $db; //compatiable for CLI mode and also speed up of it running
                $mainId = $this->generateId(false);
                $recArr["Id"] = $mainId;
            }
            Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "New record Id is " . $recArr["Id"]);
        } catch (Exception $e) {
            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 null;
        }

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

        if ($this->_postUpdateLobFields($recArr) === false) {
            $this->errorMessage = $db->ErrorMsg();
            return false;
        }

        $this->cleanCache();

        $this->recordId = $recArr["Id"];
        $this->currentRecord = null;

        $this->_postInsertRecord($recArr);
        $this->events()->trigger(__FUNCTION__ . '.post', $this, array('record', $recArr));
        return $recArr["Id"];
    }
public function insertRecord($recArr)
    {
        $this->events()->trigger(__FUNCTION__ . '.pre', $this, array('record', $recArr));
        if ($this->_isNeedGenerateId($recArr))
            $recArr["Id"] = $this->generateId();    // for certain cases, id is generated before insert

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

        if (!$this->validateInput())
            return false;

        $db = $this->getDBConnection("WRITE");

        try {
            $sql = $this->getSQLHelper()->buildInsertSQL($this, $joinValues);
            if ($sql) {
                Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Insert Sql = $sql");
                $db->query($sql, $bindValues);
            }
            //$mainId = $db->lastInsertId();
            if ($this->_isNeedGenerateId($recArr)) {
                $this->m_db = $db; //compatiable for CLI mode and also speed up of it running
                $mainId = $this->generateId(false);
                $recArr["Id"] = $mainId;
            }
            Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "New record Id is " . $recArr["Id"]);
        } catch (Exception $e) {
            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 null;
        }

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

        if ($this->_postUpdateLobFields($recArr) === false) {
            $this->errorMessage = $db->ErrorMsg();
            return false;
        }

        $this->cleanCache();

        $this->recordId = $recArr["Id"];
        $this->currentRecord = null;

        $this->_postInsertRecord($recArr);
        $this->events()->trigger(__FUNCTION__ . '.post', $this, array('record', $recArr));
        return $recArr["Id"];
    }
Insert record using given input record array

@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.