本文整理汇总了PHP中DataBase::CreateEnterpriseInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP DataBase::CreateEnterpriseInstance方法的具体用法?PHP DataBase::CreateEnterpriseInstance怎么用?PHP DataBase::CreateEnterpriseInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase::CreateEnterpriseInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NewEnterpriseSystem
private function NewEnterpriseSystem()
{
$DB = new DataBase();
$IdUser = filter_input(INPUT_POST, "IdUser");
$UserName = filter_input(INPUT_POST, "UserName");
$EnterpriseAlias = filter_input(INPUT_POST, "EnterpriseAlias");
$EnterpriseName = filter_input(INPUT_POST, "NewNameEnterprise");
$EnterpriseRFC = filter_input(INPUT_POST, "NewRfcEnterprise");
$EnterprisePassword = filter_input(INPUT_POST, "NewPasswordEnterprise");
$RoutFile = filter_input(INPUT_SERVER, "DOCUMENT_ROOT");
/* /var/services/web */
if (!file_exists($RoutFile . "/Config/Enterprise")) {
if (!($mkdir = mkdir($RoutFile . "/Config/Enterprise"))) {
XML::XmlResponse("Error", 0, "<p><b>Error</b> al crear el directorio de Empresas</p><br>Detalles:<br><br>{$mkdir}");
return 0;
}
}
$QueryComplement = "";
foreach ($_FILES as $FileName => $value) {
if ($value['error'] != UPLOAD_ERR_OK) {
XML::XmlResponse("Error", 0, "<p>" . $_FILES[$FileName]['error'] . '</p>');
return 0;
}
$TmpName = $value['tmp_name'];
$name = $value['name'];
$QueryComplement .= ",'/Config/Enterprise/{$FileName}{$name}{$EnterpriseAlias}'";
if (!($move = move_uploaded_file($TmpName, $RoutFile . "/Config/Enterprise/{$EnterpriseAlias}"))) {
XML::XmlResponse("Error", 0, "<p><b>Error</b> al escribir en el servidor el documento {$FileName}</p><br>Detalles:<br><br>{$move}");
return 0;
}
}
if ($CreateEnterprise = $DB->CreateEnterpriseInstance($EnterpriseName) != 1) {
return 0;
}
$QInsertEnterprise = "INSERT INTO Enterprises (Alias, EnterpriseName, RFC, Password, PublicFile, PrivateFile) VALUES " . "('{$EnterpriseAlias}', '{$EnterpriseName}', '{$EnterpriseRFC}', '{$EnterprisePassword}' {$QueryComplement})";
if (($ResultInser = $DB->ConsultaQuery("CSDOCS_CFDI", $QInsertEnterprise)) != 1) {
XML::XmlResponse("Error", 0, "<p><b>Error</b> al registrar la nueva empresa</p><br>Detalles:<br><br>{$ResultInser}");
return 0;
}
XML::XmlResponse("NewEnterprise", 1, "Empresa {$EnterpriseName} dada de alta con éxito");
}
示例2: NewEnterpriseSystem
private function NewEnterpriseSystem()
{
$DB = new DataBase();
$IdUser = filter_input(INPUT_POST, "IdUser");
$UserName = filter_input(INPUT_POST, "UserName");
$ManagerEnterpriseAlias = filter_input(INPUT_POST, "EnterpriseAlias");
$EnterpriseAlias = filter_input(INPUT_POST, "NewEnterpriseAlias");
$EnterpriseName = filter_input(INPUT_POST, "NewNameEnterprise");
$EnterpriseRFC = filter_input(INPUT_POST, "NewRfcEnterprise");
$EnterprisePassword = filter_input(INPUT_POST, "NewPasswordEnterprise");
$IdVolume = filter_input(INPUT_POST, "IdVolume");
$AssignedMemory = filter_input(INPUT_POST, "AssignedMemory");
$Volume = filter_input(INPUT_POST, "Volume");
$RoutFile = filter_input(INPUT_SERVER, "DOCUMENT_ROOT");
/* /var/services/web */
$CheckVersion = Version::CheckVersion();
if ($CheckVersion == 0) {
return 0;
}
$QueryDuplicated = "SELECT *FROM Enterprises WHERE Alias COLLATE utf8_bin = '{$EnterpriseAlias}'";
$ResultDuplicated = $DB->ConsultaSelect($ManagerEnterpriseAlias, $QueryDuplicated);
if ($ResultDuplicated['Estado'] != 1) {
XML::XmlResponse("Error", 0, "<p><b>Error</b> al comprobar la no existencia de la nueva empresa</p><br>Detalles:<br><br>" . $ResultDuplicated['Estado']);
return 0;
}
if (count($ResultDuplicated['ArrayDatos']) > 0) {
XML::XmlResponse("DuplicatedEnterprise", 0, "El alias de la empresa ya existe");
return 0;
}
if (!($ResultCopy = copy("{$RoutFile}/index.html", "{$RoutFile}/{$EnterpriseAlias}.html"))) {
XML::XmlResponse("Error", 0, "<p><b>Error</b> al generar el documento html de la nueva empresa</p>");
return 0;
}
if ($CreateEnterprise = $DB->CreateEnterpriseInstance($EnterpriseAlias) != 1) {
$DB->DeleteDataBase($EnterpriseAlias);
return 0;
}
$Now = date("Y-m-d H:i:s");
$QInsertEnterprise = "INSERT INTO Enterprises (Alias, EnterpriseName, RFC, Password, DischargeDate , IdVolume, AvailableMemory, TotalMemory) VALUES " . "('{$EnterpriseAlias}', '{$EnterpriseName}', '{$EnterpriseRFC}', '{$EnterprisePassword}', '{$Now}', '{$IdVolume}', {$AssignedMemory} ,{$AssignedMemory})";
$IdEnterprise = $DB->ConsultaInsertReturnId('Manager', $QInsertEnterprise);
if (!($IdEnterprise > 0)) {
$DB->DeleteDataBase($EnterpriseAlias);
XML::XmlResponse("Error", 0, "<p><b>Error</b> al registrar la nueva empresa</p><br>Detalles:<br><br>{$IdEnterprise}");
return 0;
}
$UpdateMemory = "UPDATE Volumes SET Used = Used + {$AssignedMemory}, Available = Available - {$AssignedMemory} WHERE IdVolume = {$IdVolume}";
if (($ResultUpdate = $DB->ConsultaQuery('Manager', $UpdateMemory)) != 1) {
XML::XmlResponse("Error", 0, "<p><b>Error</b> al actualizar el espacio disponible en el volúmen {$Volume}</p><br>Detalles:<br><br>{$ResultUpdate}");
return 0;
}
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = $doc->createElement("NewEnterprise");
$doc->appendChild($root);
$mensaje_ = $doc->createElement('Mensaje', "Empresa {$EnterpriseName} dada de alta con éxito");
$root->appendChild($mensaje_);
$IdEnterpriseXml = $doc->createElement("IdEnterprise", $IdEnterprise);
$root->appendChild($IdEnterpriseXml);
$EnterpriseAliasXml = $doc->createElement("EnterpriseAlias", $EnterpriseAlias);
$root->appendChild($EnterpriseAliasXml);
$EnterpriseNameXml = $doc->createElement("EnterpriseName", $EnterpriseName);
$root->appendChild($EnterpriseNameXml);
$RFCXml = $doc->createElement("RFC", $EnterpriseRFC);
$root->appendChild($RFCXml);
$DischargeDateXml = $doc->createElement("DischargeDate", $Now);
$root->appendChild($DischargeDateXml);
$TotalMemory = $doc->createElement("TotalMemory", $AssignedMemory);
$root->appendChild($TotalMemory);
$VolumeXml = $doc->createElement("Volume", $Volume);
$root->appendChild($VolumeXml);
$OccupiedMemory = $doc->createElement("OccupiedMemory", 0);
$root->appendChild($OccupiedMemory);
$FreeMemory = $doc->createElement("FreeMemory", $AssignedMemory);
$root->appendChild($FreeMemory);
header("Content-Type:text/xml");
echo $doc->saveXML();
}