|
|
@@ -298,21 +298,21 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
: $fieldName;
|
|
|
}
|
|
|
public function getID() {
|
|
|
- list($databaseName) = explode('/', $this->_namespace);
|
|
|
- if ('default_db' == $databaseName) {
|
|
|
- $idZasobDatabase = (int)DB::getPDO($databaseName)->getZasobId();
|
|
|
+ list($sourceName) = explode('/', $this->_namespace);
|
|
|
+ if ('default_db' == $sourceName || 'default_objects' == $sourceName) {
|
|
|
+ $idZasobDatabase = (int)DB::getPDO()->getZasobId();
|
|
|
if ($idZasobDatabase <= 0) throw new Exception("Missing database id");
|
|
|
$sqlNamespace = DB::getPDO()->quote($this->_namespace, PDO::PARAM_STR);
|
|
|
- $zasob = DB::getPDO()->fetchFirst("
|
|
|
- select z.ID, z.`DESC`, z.`TYPE`
|
|
|
+ $idZasob = DB::getPDO()->fetchValue("
|
|
|
+ select z.ID
|
|
|
from CRM_LISTA_ZASOBOW z
|
|
|
where z.`TYPE` = 'TABELA'
|
|
|
and z.`DESC` = {$sqlNamespace}
|
|
|
and z.PARENT_ID = {$idZasobDatabase}
|
|
|
and z.A_STATUS not in('DELETED')
|
|
|
");
|
|
|
- if ($zasob) return $zasob['ID'];
|
|
|
- $id = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [
|
|
|
+ if ($idZasob) return $idZasob;
|
|
|
+ $idZasob = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [
|
|
|
'PARENT_ID' => $idZasobDatabase,
|
|
|
'DESC' => $this->_namespace,
|
|
|
'TYPE' => "TABELA",
|
|
|
@@ -320,13 +320,14 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
|
|
|
'A_RECORD_CREATE_DATE' => "NOW()"
|
|
|
]);
|
|
|
DB::getPDO()->insert('CRM_LISTA_ZASOBOW_HIST', [
|
|
|
- 'ID_USERS2' => $id,
|
|
|
+ 'ID_USERS2' => $idZasob,
|
|
|
'PARENT_ID' => $idZasobDatabase,
|
|
|
'DESC' => $this->_namespace,
|
|
|
'TYPE' => "TABELA",
|
|
|
'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
|
|
|
'A_RECORD_CREATE_DATE' => "NOW()"
|
|
|
]);
|
|
|
+ return $idZasob;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|