protected function generateId($isBeforeInsert = true, $tableName = null, $idCloumnName = null)
    {
        // Identity type id is generated after insert is done.
        // If this method is called before insert, return null.
        if ($isBeforeInsert && $this->idGeneration == 'Identity')
            return null;

        if (!$isBeforeInsert && $this->idGeneration != 'Identity') {
            $this->errorMessage = MessageHelper::getMessage("DATA_UNABLE_GET_ID", $this->objectName);
            return false;
        }

        /* @var $genIdService genIdService */
        $genIdService = Openbizx::getService(GENID_SERVICE);
        if ($this->m_db) {
            $db = $this->m_db;
        } else {
            $db = $this->getDBConnection("READ");
        }
        $dbInfo = Openbizx::$app->getConfiguration()->getDatabaseInfo($this->databaseAliasName);
        $dbType = $dbInfo["Driver"];
        $table = $tableName ? $tableName : $this->mainTableName;
        $column = $idCloumnName ? $idCloumnName : $this->getField("Id")->column;

        try {
            $newId = $genIdService->getNewID($this->idGeneration, $db, $dbType, $table, $column);
        } catch (Exception $e) {
            $this->errorMessage = $e->getMessage();
            return false;
        }
        return $newId;
    }
protected function generateId($isBeforeInsert = true, $tableName = null, $idCloumnName = null)
    {
        // Identity type id is generated after insert is done.
        // If this method is called before insert, return null.
        if ($isBeforeInsert && $this->idGeneration == 'Identity')
            return null;

        if (!$isBeforeInsert && $this->idGeneration != 'Identity') {
            $this->errorMessage = MessageHelper::getMessage("DATA_UNABLE_GET_ID", $this->objectName);
            return false;
        }

        /* @var $genIdService genIdService */
        $genIdService = Openbizx::getService(GENID_SERVICE);
        if ($this->m_db) {
            $db = $this->m_db;
        } else {
            $db = $this->getDBConnection("READ");
        }
        $dbInfo = Openbizx::$app->getConfiguration()->getDatabaseInfo($this->databaseAliasName);
        $dbType = $dbInfo["Driver"];
        $table = $tableName ? $tableName : $this->mainTableName;
        $column = $idCloumnName ? $idCloumnName : $this->getField("Id")->column;

        try {
            $newId = $genIdService->getNewID($this->idGeneration, $db, $dbType, $table, $column);
        } catch (Exception $e) {
            $this->errorMessage = $e->getMessage();
            return false;
        }
        return $newId;
    }
protected function generateId ( $ isBeforeInsert = true , $ tableName = null , $ idCloumnName = null ) { // Identity type id is generated after insert is done. // If this method is called before insert, return null. if ( $ isBeforeInsert && $ this -> idGeneration == 'Identity' ) return null ; if ( ! $ isBeforeInsert && $ this -> idGeneration != 'Identity' ) { $ this -> errorMessage = MessageHelper :: getMessage ( "DATA_UNABLE_GET_ID" , $ this -> objectName ) ; return false ; } /* @var $genIdService genIdService */ $ genIdService = Openbizx :: getService ( GENID_SERVICE ) ; if ( $ this -> m_db ) { $ db = $ this -> m_db ; } else { $ db = $ this -> getDBConnection ( "READ" ) ; } $ dbInfo = Openbizx :: $ app -> getConfiguration ( ) -> getDatabaseInfo ( $ this -> databaseAliasName ) ; $ dbType = $ dbInfo [ "Driver" ] ; $ table = $ tableName ? $ tableName : $ this -> mainTableName ; $ column = $ idCloumnName ? $ idCloumnName : $ this -> getField ( "Id" ) -> column ; try { $ newId = $ genIdService -> getNewID ( $ this -> idGeneration , $ db , $ dbType , $ table , $ column ) ; } catch ( Exception $ e ) { $ this -> errorMessage = $ e -> getMessage ( ) ; return false ; } return $ newId ; }
Generate Id according to the IdGeneration attribute

@param boolean $isBeforeInsert
@param string $tableName
@param string $idCloumnName
@return long|string|boolean
Generate Id according to the IdGeneration attribute