/** * Generate Id according to the IdGeneration attribute * * @param boolean $isBeforeInsert * @param string $tableName * @param string $idCloumnName * @return long|string|boolean */ 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->m_IdGeneration == 'Identity') { return null; } if (!$isBeforeInsert && $this->m_IdGeneration != 'Identity') { $this->m_ErrorMessage = BizSystem::getMessage("DATA_UNABLE_GET_ID", $this->m_Name); return false; } /* @var $genIdService genIdService */ $genIdService = BizSystem::getService(GENID_SERVICE); $db = $this->getDBConnection(); $dbInfo = BizSystem::Configuration()->getDatabaseInfo($this->m_Database); $dbType = $dbInfo["Driver"]; $table = $tableName ? $tableName : $this->m_MainTable; $column = $idCloumnName ? $idCloumnName : $this->getField("Id")->m_Column; try { $newId = $genIdService->getNewID($this->m_IdGeneration, $db, $dbType, $table, $column); } catch (Exception $e) { $this->m_ErrorMessage = $e->getMessage(); return false; } return $newId; }