本文整理汇总了PHP中AssetModel::GetDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetModel::GetDatabase方法的具体用法?PHP AssetModel::GetDatabase怎么用?PHP AssetModel::GetDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetModel
的用法示例。
在下文中一共展示了AssetModel::GetDatabase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Save
public function Save($blnForceInsert = false, $blnForceUpdate = false)
{
if (!$this->__blnRestored || $blnForceInsert) {
$this->CreatedBy = QApplication::$objUserAccount->UserAccountId;
$this->CreationDate = new QDateTime(QDateTime::Now);
parent::Save($blnForceInsert, $blnForceUpdate);
$objDatabase = AssetModel::GetDatabase();
$strQuery = sprintf('INSERT INTO `asset_model_custom_field_helper` (`asset_model_id`) VALUES (%s);', $this->AssetModelId);
$objDatabase->NonQuery($strQuery);
} else {
$this->ModifiedBy = QApplication::$objUserAccount->UserAccountId;
parent::Save($blnForceInsert, $blnForceUpdate);
}
}
示例2: 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;
示例3: btnNext_Click
//.........这里部分代码省略.........
}
}
} else {
$intDepreciationId = null;
}
//
$objAssetModel = false;
if (!$strShortDescription || $intCategoryId === false || $intManufacturerId === false || $intDepreciationId === false) {
//$blnError = true;
//echo sprintf("Desc: %s AssetCode: %s Cat: %s Man: %s<br/>", $strShortDescription, $strAssetModelCode, $intCategoryId, $intManufacturerId);
//break;
$strAssetModel = null;
$this->intSkippedRecordCount++;
$this->PutSkippedRecordInFile($file_skipped, $strRowArray);
continue;
} else {
//$blnError = false;
$strAssetModel = strtolower(sprintf("%s_%s_%s_%s", $strAssetModelCode, $strShortDescription, $intCategoryId, $intManufacturerId));
if ($this->lstImportAction->SelectedValue == 2) {
$intItemId = intval(trim($strRowArray[$this->intItemIdKey]));
if ($intItemId > 0 && array_key_exists($intItemId, $arrAssetModelId)) {
$objAssetModelArray = AssetModel::LoadArrayBySearchHelper(null, null, null, null, null, null, null, null, null, null, null, null, $intItemId);
if ($objAssetModelArray) {
$objAssetModel = $objAssetModelArray[0];
}
}
} else {
$intItemId = 0;
}
}
if ($strAssetModel && !$intItemId && !$this->in_array_nocase($strAssetModel, $strAssetModelArray)) {
// Custom Fields Section
$strCFVArray = array();
$objDatabase = CustomField::GetDatabase();
$blnCheckCFVError = false;
// Asset Model Custom Field import
foreach ($arrModelCustomField as $objCustomField) {
if ($objCustomField->CustomFieldQtypeId != 2) {
$strCSDescription = trim($strRowArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]);
$strCSDescription = strlen($strCSDescription) > 0 ? addslashes($strCSDescription) : addslashes($this->txtMapDefaultValueArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]->Text);
$strCFVArray[$objCustomField->CustomFieldId] = strlen($strCSDescription) > 0 ? sprintf("'%s'", $strCSDescription) : "NULL";
} else {
$objDatabase = AssetModel::GetDatabase();
$strCSDescription = addslashes(trim($strRowArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]));
$blnInList = false;
foreach (CustomFieldValue::LoadArrayByCustomFieldId($objCustomField->CustomFieldId) as $objCustomFieldValue) {
if (strtolower($objCustomFieldValue->ShortDescription) == strtolower($strCSDescription)) {
//$intCustomFieldValueId = $objCustomFieldValue->CustomFieldValueId;
$blnInList = true;
break;
}
}
// Add the CustomFieldValue
// Removed adding new 'select' values
/*if (!$blnInList && !in_array($strCSDescription, $strAddedCFVArray)) {
$strQuery = sprintf("INSERT INTO custom_field_value (custom_field_id, short_description, created_by, creation_date) VALUES (%s, '%s', %s, NOW());", $objCustomField->CustomFieldId, $strCSDescription, $_SESSION['intUserAccountId']);
$objDatabase->NonQuery($strQuery);
$strAddedCFVArray[] = $strCSDescription;
}
else*/
if (!$blnInList && $this->lstMapDefaultValueArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedValue != null) {
$strCSDescription = $this->lstMapDefaultValueArray[$intModelCustomFieldKeyArray[$objCustomField->CustomFieldId]]->SelectedName;
} elseif (!$blnInList) {
$blnCheckCFVError = true;
break;
}
示例4: DeleteAllAssets
/**
* Deletes all associated Assets
* @return void
*/
public function DeleteAllAssets()
{
if (is_null($this->intAssetModelId)) {
throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAsset on this unsaved AssetModel.');
}
// Get the Database Object for this Class
$objDatabase = AssetModel::GetDatabase();
// Perform the SQL Query
$objDatabase->NonQuery('
DELETE FROM
`asset`
WHERE
`asset_model_id` = ' . $objDatabase->SqlVariable($this->intAssetModelId) . '
');
}
示例5: DeleteAllAssetCustomFieldAssetModels
/**
* Deletes all associated AssetCustomFieldAssetModels
* @return void
*/
public function DeleteAllAssetCustomFieldAssetModels()
{
if (is_null($this->intAssetModelId)) {
throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAssetCustomFieldAssetModel on this unsaved AssetModel.');
}
// Get the Database Object for this Class
$objDatabase = AssetModel::GetDatabase();
// Journaling
if ($objDatabase->JournalingDatabase) {
foreach (AssetCustomFieldAssetModel::LoadArrayByAssetModelId($this->intAssetModelId) as $objAssetCustomFieldAssetModel) {
$objAssetCustomFieldAssetModel->Journal('DELETE');
}
}
// Perform the SQL Query
$objDatabase->NonQuery('
DELETE FROM
`asset_custom_field_asset_model`
WHERE
`asset_model_id` = ' . $objDatabase->SqlVariable($this->intAssetModelId) . '
');
}