本文整理汇总了PHP中DBObjectSet::count方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObjectSet::count方法的具体用法?PHP DBObjectSet::count怎么用?PHP DBObjectSet::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjectSet
的用法示例。
在下文中一共展示了DBObjectSet::count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: StoreObject
/**
* Store an object in the database and remember the mapping
* between its original ID and the newly created ID in the database
*/
protected function StoreObject($sClass, $oTargetObj, $iSrcId, $bSearch = false, $bUpdateKeyCacheOnly = false)
{
$iObjId = 0;
try {
if ($bSearch) {
// Check if the object does not already exist, based on its usual reconciliation keys...
$aReconciliationKeys = MetaModel::GetReconcKeys($sClass);
if (count($aReconciliationKeys) > 0) {
// Some reconciliation keys have been defined, use them to search for the object
$oSearch = new DBObjectSearch($sClass);
$iConditionsCount = 0;
foreach ($aReconciliationKeys as $sAttCode) {
if ($oTargetObj->Get($sAttCode) != '') {
$oSearch->AddCondition($sAttCode, $oTargetObj->Get($sAttCode), '=');
$iConditionsCount++;
}
}
if ($iConditionsCount > 0) {
$oSet = new DBObjectSet($oSearch);
if ($oSet->count() == 1) {
// The object already exists, reuse it
$oExistingObject = $oSet->Fetch();
$iObjId = $oExistingObject->GetKey();
}
}
}
}
if ($iObjId == 0) {
if ($oTargetObj->IsNew()) {
if (!$bUpdateKeyCacheOnly) {
$iObjId = $oTargetObj->DBInsertNoReload();
$this->m_iCountCreated++;
}
} else {
$iObjId = $oTargetObj->GetKey();
if (!$bUpdateKeyCacheOnly) {
$oTargetObj->DBUpdate();
}
}
}
} catch (Exception $e) {
SetupPage::log_error("An object could not be recorded - {$sClass}/{$iSrcId} - " . $e->getMessage());
$this->m_aErrors[] = "An object could not be recorded - {$sClass}/{$iSrcId} - " . $e->getMessage();
}
$aParentClasses = MetaModel::EnumParentClasses($sClass);
$aParentClasses[] = $sClass;
foreach ($aParentClasses as $sObjClass) {
$this->m_aKeys[$sObjClass][$iSrcId] = $iObjId;
}
$this->m_aObjectsCache[$sClass][$iObjId] = $oTargetObj;
}
示例2: IsPowerUSer
/**
* Determine if the current user can be considered as being a portal power user
*/
function IsPowerUSer()
{
$iUserID = UserRights::GetUserId();
$sOQLprofile = "SELECT URP_Profiles AS p JOIN URP_UserProfile AS up ON up.profileid=p.id WHERE up.userid = :user AND p.name = :profile";
$oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQLprofile), array(), array('user' => $iUserID, 'profile' => PORTAL_POWER_USER_PROFILE));
$bRes = $oProfileSet->count() > 0;
return $bRes;
}
示例3: DeleteConnectedNetworkDevice
protected function DeleteConnectedNetworkDevice()
{
$iNetworkDeviceID = $this->Get('networkdevice_id');
$iDeviceID = $this->Get('connectableci_id');
$oDevice = MetaModel::GetObject('ConnectableCI', $this->Get('connectableci_id'));
$sOQL = "SELECT lnkConnectableCIToNetworkDevice WHERE connectableci_id = :device AND networkdevice_id = :network AND network_port = :nwport AND device_port = :devport";
$oConnectionSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('network' => $this->Get('connectableci_id'), 'device' => $this->Get('networkdevice_id'), 'devport' => $this->Get('network_port'), 'nwport' => $this->Get('device_port')));
$iAlreadyExist = $oConnectionSet->count();
if (get_class($oDevice) == 'NetworkDevice' && $iAlreadyExist != 0) {
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
if (UserRights::IsImpersonated()) {
$sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUser(), UserRights::GetUser());
} else {
$sUserString = UserRights::GetUser();
}
$oMyChange->Set("userinfo", $sUserString);
$iChangeId = $oMyChange->DBInsert();
$oConnection = $oConnectionSet->Fetch();
$oConnection->DBDeleteTracked($oMyChange);
}
}