当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::GetDatabase方法代码示例

本文整理汇总了PHP中Location::GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::GetDatabase方法的具体用法?PHP Location::GetDatabase怎么用?PHP Location::GetDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Location的用法示例。


在下文中一共展示了Location::GetDatabase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sprintf

<?php

/* This script allows to add new location 'Archived' (location_id=6)
 * in the existing database
 */
require_once '../includes/prepend.inc.php';
QApplication::Authenticate();
$objDatabase = Location::GetDatabase();
// Load the Location Object by location_id=6
$objLocation = Location::Load(6);
// If the location exist or already updated
if ($objLocation && $objLocation->ShortDescription != 'Archived') {
    $objDatabase->NonQuery("SET FOREIGN_KEY_CHECKS = 0;");
    // Update location_id=6 to 'Archived'
    $strQuery = sprintf("UPDATE `location`\n                      SET `short_description`='Archived', `created_by`=NULL, `modified_by`=NULL, `creation_date`=NULL, `modified_date`=NULL, `long_description`=NULL\n                      WHERE `location_id`='6';");
    $objDatabase->NonQuery($strQuery);
    // Save existing location with new location_id
    $strQuery = sprintf("INSERT INTO `location` VALUES\n    (NULL, '{$objLocation->ShortDescription}', '{$objLocation->LongDescription}', '{$objLocation->CreatedBy}', '" . $objLocation->CreationDate->PHPDate('Y-m-d H:i:s') . "', '{$objLocation->ModifiedBy}', '{$objLocation->ModifiedDate}');");
    // Save and reload old location
    $objDatabase->NonQuery($strQuery);
    $objNewLocation = Location::LoadByShortDescription($objLocation->ShortDescription);
    // Get new location_id
    $objNewLocationId = $objNewLocation->LocationId;
    // Update all foreign keys and links
    // Added `modified_date`=`modified_date` to avoid the attribute "ON UPDATE CURRENT_TIMESTAMP"
    $strQuery = sprintf("UPDATE `asset`\n                      SET `location_id`='%s', `modified_date`=`modified_date`\n                      WHERE `location_id`='6';", $objNewLocationId);
    $objDatabase->NonQuery($strQuery);
    $strQuery = sprintf("UPDATE `audit_scan`\n                      SET `location_id`='%s'\n                      WHERE `location_id`='6';", $objNewLocationId);
    $objDatabase->NonQuery($strQuery);
    $strQuery = sprintf("UPDATE `inventory_location`\n                      SET `location_id`='%s', `modified_date`=`modified_date`\n                      WHERE `location_id`='6';", $objNewLocationId);
    $objDatabase->NonQuery($strQuery);
开发者ID:brustj,项目名称:tracmor,代码行数:31,代码来源:asset_archive_update.php

示例2: DeleteAllInventoryTransactionsAsDestination

    /**
     * Deletes all associated InventoryTransactionsAsDestination
     * @return void
     */
    public function DeleteAllInventoryTransactionsAsDestination()
    {
        if (is_null($this->intLocationId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateInventoryTransactionAsDestination on this unsaved Location.');
        }
        // Get the Database Object for this Class
        $objDatabase = Location::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (InventoryTransaction::LoadArrayByDestinationLocationId($this->intLocationId) as $objInventoryTransaction) {
                $objInventoryTransaction->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`inventory_transaction`
				WHERE
					`destination_location_id` = ' . $objDatabase->SqlVariable($this->intLocationId) . '
			');
    }
开发者ID:proxymoron,项目名称:tracmor,代码行数:25,代码来源:LocationGen.class.php

示例3: btnNext_Click


//.........这里部分代码省略.........
                 $objNewLocation->Save();
                 $this->objNewLocationArray[$objNewLocation->LocationId] = $objNewLocation->ShortDescription;
             }
             $this->objNewLocationArray = array();
             $this->objNewCategoryArray = array();
             $this->objNewManufacturerArray = array();
             $this->objNewAssetModelArray = array();
             $this->strModelValuesArray = array();
             $this->blnImportEnd = false;
             $j = 1;
             $strLocationValuesArray = array();
             // Add all unique locations in database
             foreach ($this->strFilePathArray as $strFilePath) {
                 $this->FileCsvData->load($strFilePath);
                 if ($j != 1) {
                     //$this->FileCsvData->appendRow($this->FileCsvData->getHeaders());
                 }
                 // Location Import
                 for ($i = 0; $i < $this->FileCsvData->countRows(); $i++) {
                     $strRowArray = $this->FileCsvData->getRow($i);
                     if (trim($strRowArray[$this->intLocationKey]) && !$this->in_array_nocase(trim($strRowArray[$this->intLocationKey]), $strLocationArray)) {
                         $strLocationArray[] = trim($strRowArray[$this->intLocationKey]);
                         /*$objNewLocation = new Location();
                           $objNewLocation->ShortDescription = addslashes(trim($strRowArray[$this->intLocationKey]));
                           $objNewLocation->Save();*/
                         $strLocationValuesArray[] = sprintf("('%s', '%s', NOW())", addslashes(trim($strRowArray[$this->intLocationKey])), $_SESSION['intUserAccountId']);
                         $strNewLocation[] = addslashes(trim($strRowArray[$this->intLocationKey]));
                         //$this->objNewLocationArray[$objNewLocation->LocationId] = $objNewLocation->ShortDescription;
                     }
                 }
                 $j++;
             }
             if (count($strLocationValuesArray)) {
                 $objDatabase = Location::GetDatabase();
                 $objDatabase->NonQuery(sprintf("INSERT INTO `location` (`short_description`, `created_by`, `creation_date`) VALUES %s;", implode(", ", $strLocationValuesArray)));
                 $intStartId = $objDatabase->InsertId();
                 for ($i = 0; $i < count($strNewLocation); $i++) {
                     $this->objNewLocationArray[$intStartId + $i] = $strNewLocation[$i];
                 }
             }
             $this->btnNext->RemoveAllActions('onclick');
             // Add new ajax actions for button
             $this->btnNext->AddAction(new QClickEvent(), new QAjaxAction('btnNext_Click'));
             $this->btnNext->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnNext));
             $this->btnNext->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnNext_Click'));
             $this->btnNext->AddAction(new QEnterKeyEvent(), new QToggleEnableAction($this->btnNext));
             $this->btnNext->AddAction(new QEnterKeyEvent(), new QTerminateAction());
             $this->btnNext->Warning = "Locations have been imported. Please wait...";
             $this->intImportStep = 2;
             $this->intCurrentFile = 0;
             $this->strSelectedValueArray = array();
             // New locations
             $this->dtgLocation = new QDataGrid($this);
             $this->dtgLocation->Name = 'location_list';
             $this->dtgLocation->CellPadding = 5;
             $this->dtgLocation->CellSpacing = 0;
             $this->dtgLocation->CssClass = "datagrid";
             $this->dtgLocation->UseAjax = true;
             $this->dtgLocation->ShowColumnToggle = false;
             $this->dtgLocation->ShowExportCsv = false;
             $this->dtgLocation->ShowHeader = false;
             $this->dtgLocation->AddColumn(new QDataGridColumnExt('Location', '<?= $_ITEM ?>', 'CssClass="dtg_column"', 'HtmlEntities="false"'));
             // New categories
             $this->dtgCategory = new QDataGrid($this);
             $this->dtgCategory->Name = 'category_list';
             $this->dtgCategory->CellPadding = 5;
开发者ID:proxymoron,项目名称:tracmor,代码行数:67,代码来源:asset_import.php

示例4: btnNext_Click


//.........这里部分代码省略.........
                         $objLocation = null;
                         if ($this->lstImportAction->SelectedValue == 2) {
                             $intItemId = intval(trim($strRowArray[$this->intItemIdKey]));
                             foreach ($objLocationArray as $objItem) {
                                 if ($objItem->LocationId == $intItemId) {
                                     $objLocation = $objItem;
                                     break;
                                 }
                             }
                         } else {
                             $intItemId = 0;
                         }
                         // Create action
                         if (trim($strRowArray[$this->intLocationKey]) && (!$intItemId || !$objLocation) && !$this->in_array_nocase(trim($strRowArray[$this->intLocationKey]), $strLocationArray)) {
                             $strLocationArray[] = trim($strRowArray[$this->intLocationKey]);
                             $strLocationDescription = "";
                             if (isset($this->intLocationDescriptionKey)) {
                                 if (trim($strRowArray[$this->intLocationDescriptionKey])) {
                                     $strLocationDescription = trim($strRowArray[$this->intLocationDescriptionKey]);
                                 } else {
                                     $strLocationDescription = isset($this->txtMapDefaultValueArray[$this->intLocationDescriptionKey]) ? trim($this->txtMapDefaultValueArray[$this->intLocationDescriptionKey]->Text) : '';
                                 }
                             }
                             $strLocationValuesArray[] = sprintf("('%s', '%s', '%s', NOW())", addslashes(trim($strRowArray[$this->intLocationKey])), addslashes($strLocationDescription), $_SESSION['intUserAccountId']);
                             $strNewLocationArray[] = addslashes(trim($strRowArray[$this->intLocationKey]));
                             /*$strCFVArray = array();
                               // Custom Field import
                               foreach ($arrItemCustomField as $objCustomField) {
                                 if ($objCustomField->CustomFieldQtypeId != 2) {
                                  	 $strShortDescription = (trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]])) ? addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]])) : addslashes($this->txtMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->Text);
                                   $strCFVArray[$objCustomField->CustomFieldId] = ($strShortDescription) ? sprintf("'%s'", $strShortDescription) : "NULL";
                                 }
                                     else {
                                     	$objDatabase = CustomField::GetDatabase();
                                       $strShortDescription = addslashes(trim($strRowArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]));
                                       $blnInList = false;
                                       foreach (CustomFieldValue::LoadArrayByCustomFieldId($objCustomField->CustomFieldId) as $objCustomFieldValue) {
                             					  if (strtolower($objCustomFieldValue->ShortDescription) == strtolower($strShortDescription)) {
                                 					$blnInList = true;
                                 					break;
                             					  }
                             					}
                             					// Add the CustomFieldValue
                             					if (!$blnInList && !in_array($strShortDescription, $strAddedCFVArray)) {
                             						$strQuery = sprintf("INSERT INTO custom_field_value (custom_field_id, short_description, created_by, creation_date) VALUES (%s, '%s', %s, NOW());", $objCustomField->CustomFieldId, $strShortDescription, $_SESSION['intUserAccountId']);
                             						$objDatabase->NonQuery($strQuery);
                             						$strAddedCFVArray[] = $strShortDescription;
                             					}
                             					elseif (!$blnInList && $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedValue != null) {
                                         $strShortDescription = $this->lstMapDefaultValueArray[$intItemCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedName;
                              					}
                                       if ($strShortDescription/* && $intCustomFieldValueId*/
                             /*) {
                                          $strCFVArray[$objCustomField->CustomFieldId] = sprintf("'%s'", $strShortDescription);
                                        }
                                        else {
                                          $strCFVArray[$objCustomField->CustomFieldId] = "NULL";
                                        }
                                      }
                               }
                               if (isset($strCFVArray) && count($strCFVArray)) {
                                 $strItemCFVArray[] = implode(', ', $strCFVArray);
                               }
                               else {
                                 $strItemCFVArray[] = "";
                               }*/
开发者ID:jdellinger,项目名称:tracmor,代码行数:67,代码来源:location_import.php


注:本文中的Location::GetDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。