/** * @param Folder $folder * @return bool */ function CreateFolder(&$folder) { if (!$this->_connector->Execute($this->_commandCreator->SelectForCreateFolder($folder))) { return false; } else { $row = $this->_connector->GetNextRecord(); $folder->FolderOrder = $row && isset($row->norder) ? (int) ($row->norder + 1) : 0; } if (!$this->_connector->Execute($this->_commandCreator->CreateFolder($folder))) { return false; } $folder->IdDb = $this->_connector->GetLastInsertId(); if (!$this->_connector->Execute($this->_commandCreator->CreateFolderTree($folder))) { return false; } if (!$this->_connector->Execute($this->_commandCreator->SelectForCreateFolderTree($folder))) { return false; } else { $result = array(); while (($row = $this->_connector->GetNextRecord()) != false) { $IdParent = $row && isset($row->id_parent) ? (int) $row->id_parent : -1; $Level = $row && isset($row->folder_level) ? (int) ($row->folder_level + 1) : 0; $result[] = array($IdParent, $Level); } if ($result) { foreach ($result as $folderData) { if (!is_array($folderData)) { continue; } $folder->IdParent = $folderData[0]; $folder->Level = $folderData[1]; if (!$this->_connector->Execute($this->_commandCreator->CreateSelectFolderTree($folder))) { return false; } } } } return true; }