本文整理汇总了PHP中PearDatabase::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP PearDatabase::getInstance方法的具体用法?PHP PearDatabase::getInstance怎么用?PHP PearDatabase::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PearDatabase
的用法示例。
在下文中一共展示了PearDatabase::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/** Constructor which will set the column_fields in this object
*/
function __construct()
{
global $log;
$this->column_fields = getColumnFields(get_class($this));
$this->db = PearDatabase::getInstance();
$this->log = $log;
}
示例2: getReportScheduleInfo
public function getReportScheduleInfo()
{
$adb = PearDatabase::getInstance();
if (!empty($this->id)) {
$cachedInfo = VTCacheUtils::lookupReport_ScheduledInfo($this->user->id, $this->id);
if ($cachedInfo == false) {
$result = $adb->pquery('SELECT * FROM vtiger_scheduled_reports WHERE reportid=?', array($this->id));
if ($adb->num_rows($result) > 0) {
$reportScheduleInfo = $adb->raw_query_result_rowdata($result, 0);
$scheduledInterval = !empty($reportScheduleInfo['schedule']) ? Zend_Json::decode($reportScheduleInfo['schedule']) : array();
$scheduledRecipients = !empty($reportScheduleInfo['recipients']) ? Zend_Json::decode($reportScheduleInfo['recipients']) : array();
VTCacheUtils::updateReport_ScheduledInfo($this->user->id, $this->id, true, $reportScheduleInfo['format'], $scheduledInterval, $scheduledRecipients, $reportScheduleInfo['next_trigger_time']);
$cachedInfo = VTCacheUtils::lookupReport_ScheduledInfo($this->user->id, $this->id);
}
}
if ($cachedInfo) {
$this->isScheduled = $cachedInfo['isScheduled'];
$this->scheduledFormat = $cachedInfo['scheduledFormat'];
$this->scheduledInterval = $cachedInfo['scheduledInterval'];
$this->scheduledRecipients = $cachedInfo['scheduledRecipients'];
$this->scheduledTime = $cachedInfo['scheduledTime'];
return true;
}
}
return false;
}
示例3: __construct
function __construct()
{
global $root_directory, $current_language, $mod_strings;
$this->db = PearDatabase::getInstance();
$this->root_directory = $root_directory;
$this->mod_strings = $mod_strings;
}
示例4: process
public function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$crmid = $request->get('record');
$adb = PearDatabase::getInstance();
$sql1 = "DELETE FROM vtiger_pdfmaker_images WHERE crmid=?";
$adb->pquery($sql1, array($crmid));
$sql2 = "INSERT INTO vtiger_pdfmaker_images (crmid, productid, sequence, attachmentid, width, height) VALUES (?, ?, ?, ?, ?, ?)";
$R_Data = $request->getAll();
foreach ($R_Data as $key => $value) {
if (strpos($key, "img_") !== false) {
list($bin, $productid, $sequence) = explode("_", $key);
if ($value != "no_image") {
$width = $R_Data["width_" . $productid . "_" . $sequence];
$height = $R_Data["height_" . $productid . "_" . $sequence];
if (!is_numeric($width) || $width > 999) {
$width = 0;
}
if (!is_numeric($height) || $height > 999) {
$height = 0;
}
} else {
$height = $width = $value = 0;
}
$adb->pquery($sql2, array($crmid, $productid, $sequence, $value, $width, $height));
}
}
}
示例5: requestForgotPassword
public function requestForgotPassword($request)
{
$request = new Vtiger_Request($request);
$adb = PearDatabase::getInstance();
$username = vtlib_purify($request->get('user_name'));
$result = $adb->pquery('select id,email1 from vtiger_users where user_name = ? ', array($username));
if ($adb->num_rows($result) > 0) {
$email = $adb->query_result($result, 0, 'email1');
}
if (strcasecmp($request->get('emailId'), $email) === 0) {
$userId = $adb->query_result($result, 0, 'id');
$time = time();
$options = array('handler_path' => 'modules/Users/handlers/ForgotPassword.php', 'handler_class' => 'Users_ForgotPassword_Handler', 'handler_function' => 'changePassword', 'handler_data' => array('username' => $username, 'email' => $email, 'time' => $time, 'hash' => md5($username . $time)));
$trackURL = Vtiger_ShortURL_Helper::generateURL($options);
$data = ['sysname' => 'UsersForgotPassword', 'to_email' => $email, 'module' => 'Users', 'record' => $userId, 'trackURL' => $trackURL];
$recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailTemplates');
$status = $recordModel->sendMailFromTemplate($data);
$site_URL = vglobal('site_URL') . 'index.php?modules=Users&view=Login';
if ($status === 1) {
header('Location: ' . $site_URL . '&status=1');
} else {
header('Location: ' . $site_URL . '&statusError=1');
}
} else {
$site_URL = vglobal('site_URL') . 'index.php?modules=Users&view=Login';
header('Location: ' . $site_URL . '&fpError=1');
}
}
示例6: handleEvent
public function handleEvent($handlerType, $entityData)
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
$moduleName = $entityData->getModuleName();
if ($moduleName == 'SalesOrder') {
$soId = $entityData->getId();
$data = $entityData->getData();
if ($data['enable_recurring'] == 'on' || $data['enable_recurring'] == 1) {
$frequency = $data['recurring_frequency'];
$startPeriod = getValidDBInsertDateValue($data['start_period']);
$endPeriod = getValidDBInsertDateValue($data['end_period']);
$paymentDuration = $data['payment_duration'];
$invoiceStatus = $data['invoicestatus'];
if (isset($frequency) && $frequency != '' && $frequency != '--None--') {
$check_query = "SELECT * FROM vtiger_invoice_recurring_info WHERE salesorderid=?";
$check_res = $adb->pquery($check_query, array($soId));
$noofrows = $adb->num_rows($check_res);
if ($noofrows > 0) {
$row = $adb->query_result_rowdata($check_res, 0);
$query = "UPDATE vtiger_invoice_recurring_info SET recurring_frequency=?, start_period=?, end_period=?, payment_duration=?, invoice_status=? WHERE salesorderid=?";
$params = array($frequency, $startPeriod, $endPeriod, $paymentDuration, $invoiceStatus, $soId);
} else {
$query = "INSERT INTO vtiger_invoice_recurring_info VALUES (?,?,?,?,?,?,?)";
$params = array($soId, $frequency, $startPeriod, $endPeriod, $startPeriod, $paymentDuration, $invoiceStatus);
}
$adb->pquery($query, $params);
}
} else {
$query = "DELETE FROM vtiger_invoice_recurring_info WHERE salesorderid = ?";
$adb->pquery($query, array($soId));
}
}
}
示例7: NoteBookCreate
function NoteBookCreate(Vtiger_Request $request)
{
$adb = PearDatabase::getInstance();
$userModel = Users_Record_Model::getCurrentUserModel();
$linkId = $request->get('linkId');
$noteBookName = $request->get('notePadName');
$noteBookContent = $request->get('notePadContent');
$blockid = $request->get('blockid');
$isdefault = $request->get('isdefault');
$width = $request->get('width');
$height = $request->get('height');
$date_var = date("Y-m-d H:i:s");
$date = $adb->formatDate($date_var, true);
$dataValue = array();
$dataValue['contents'] = $noteBookContent;
$dataValue['lastSavedOn'] = $date;
$data = Zend_Json::encode((object) $dataValue);
$size = Zend_Json::encode(array('width' => $width, 'height' => $height));
$query = "INSERT INTO vtiger_module_dashboard(`linkid`, `blockid`, `filterid`, `title`, `data`, `isdefault`, `size`) VALUES(?,?,?,?,?,?,?)";
$params = array($linkId, $blockid, 0, $noteBookName, $data, $isdefault, $size);
$adb->pquery($query, $params);
$id = $adb->getLastInsertID();
$result = array();
$result['success'] = TRUE;
$result['widgetId'] = $id;
$response = new Vtiger_Response();
$response->setResult($result);
$response->emit();
}
示例8: handleEvent
function handleEvent($eventName, $entityData)
{
global $current_user;
$db = PearDatabase::getInstance();
$moduleName = $entityData->getModuleName();
//Specific to VAS
if ($moduleName == 'Users') {
return;
}
//END
$recordId = $entityData->getId();
$vtEntityDelta = new VTEntityDelta();
$newEntityData = $vtEntityDelta->getNewEntity($moduleName, $recordId);
$recordValues = $newEntityData->getData();
$isAssignToModified = $this->isAssignToChanged($moduleName, $recordId, $current_user);
if (!$isAssignToModified) {
return;
}
$wsModuleName = $this->getWsModuleName($moduleName);
if ($wsModuleName == "Calendar") {
$wsModuleName = vtws_getCalendarEntityType($recordId);
}
$handler = vtws_getModuleHandlerFromName($wsModuleName, $current_user);
$meta = $handler->getMeta();
$recordWsValues = DataTransform::sanitizeData($recordValues, $meta);
$syncServer = new SyncServer();
$syncServer->markRecordAsDeleteForAllCleints($recordWsValues);
}
示例9: updateProgressMilestone
public function updateProgressMilestone($id)
{
$adb = PearDatabase::getInstance();
//TODO need to handle security
if (!isRecordExists($id)) {
return;
}
$focus = CRMEntity::getInstance($this->getName());
$relatedListMileston = $focus->get_dependents_list($id, $this->getId(), getTabid('ProjectTask'));
$resultMileston = $adb->query($relatedListMileston['query']);
$num = $adb->num_rows($resultMileston);
$estimatedWorkTime = 0;
$progressInHours = 0;
for ($i = 0; $i < $num; $i++) {
$row = $adb->query_result_rowdata($resultMileston, $i);
$estimatedWorkTime += $row['estimated_work_time'];
$recordProgress = $row['estimated_work_time'] * (int) $row['projecttaskprogress'] / 100;
$progressInHours += $recordProgress;
}
if (!$estimatedWorkTime) {
return;
}
$projectMilestoneProgress = round(100 * $progressInHours / $estimatedWorkTime);
$focus->retrieve_entity_info($id, $this->getName());
$focus->column_fields['projectmilestone_progress'] = $projectMilestoneProgress . '%';
$focus->column_fields['mode'] = 'edit';
$focus->saveentity($this->getName(), $id);
}
示例10: beforeGetTaskform
public function beforeGetTaskform($transferData)
{
${"GLOBALS"}["nwklyv"] = "transferData";
$emzpvn = "availableFileActions";
$dboktonzzwl = "adb";
global $current_user;
${$dboktonzzwl} = \PearDatabase::getInstance();
$washibvkmmrl = "data";
list(${$washibvkmmrl}, ${${"GLOBALS"}["kosjnvnqt"]}) = ${${"GLOBALS"}["nwklyv"]};
${$emzpvn} = \Workflow\FileAction::getAvailableActions($this->parameter["module"]);
if (empty($this->parameter["width"])) {
${"GLOBALS"}["pnloqnoxghmc"] = "width";
${${"GLOBALS"}["pnloqnoxghmc"]} = 600;
} else {
$qdistlen = "width";
${$qdistlen} = intval($this->parameter["width"]);
}
$gsuayydy = "transferData";
$viewer->assign("field", $this->field);
$viewer->assign("width", ${${"GLOBALS"}["ruujows"]});
$viewer->assign("availableFileActions", ${${"GLOBALS"}["benaiftkv"]});
$viewer->assign("fileactions_" . $this->field, $viewer->fetch("modules/Settings/Workflow2/helpers/FileActions.tpl"));
$this->addInlineJS(${${"GLOBALS"}["nblfndkfu"]});
return ${$gsuayydy};
}
示例11: getRelatedSummary
public function getRelatedSummary($query)
{
$db = PearDatabase::getInstance();
$relationQuery = preg_replace("/[ \t\n\r]+/", " ", $query);
$position = stripos($relationQuery, ' from ');
if ($position) {
$split = explode(' FROM ', $relationQuery);
$mainQuery = '';
for ($i = 1; $i < count($split); $i++) {
$mainQuery = $mainQuery . ' FROM ' . $split[$i];
}
}
// Calculate total working time
$result = $db->query('SELECT SUM(vtiger_osstimecontrol.sum_time) AS sumtime' . $mainQuery);
$totalTime = $db->getSingleValue($result);
// Calculate total working time divided into users
$result = $db->query('SELECT SUM(vtiger_osstimecontrol.sum_time) AS sumtime, vtiger_crmentity.smownerid' . $mainQuery . ' GROUP BY vtiger_crmentity.smownerid');
$userTime = [];
$count = 1;
while ($row = $db->fetch_array($result)) {
$smownerid = Vtiger_Functions::getOwnerRecordLabel($row['smownerid']);
$userTime[] = ['name' => [$count, $smownerid], 'initial' => [$count, Vtiger_Functions::getInitials($smownerid)], 'data' => [$count, $row['sumtime']]];
$count++;
}
return ['totalTime' => $totalTime, 'userTime' => $userTime];
}
示例12: process
public function process(Vtiger_Request $request) {
$viewer = $this->getViewer($request);
$adb = PearDatabase::getInstance();
if (is_dir("modules/PDFMaker/resources/mpdf")) {
$this->invokeExposedMethod('getList', $request);
} else {
$mb_string_exists = function_exists("mb_get_info");
if ($mb_string_exists === false) {
$viewer->assign("MB_STRING_EXISTS", 'false');
} else {
$viewer->assign("MB_STRING_EXISTS", 'true');
}
$step = 1;
$current_step = 1;
$total_steps = 2;
$viewer->assign("STEP", $step);
$viewer->assign("CURRENT_STEP", $current_step);
$viewer->assign("TOTAL_STEPS", $total_steps);
$viewer->view('Install.tpl', 'PDFMaker');
}
}
示例13: handleEvent
function handleEvent($eventName, $entityData)
{
if (in_array($eventName, ['vtiger.entity.link.after', 'vtiger.entity.unlink.after'])) {
$fields = Vtiger_MultiReferenceValue_UIType::getFieldsByModules($entityData['sourceModule'], $entityData['destinationModule']);
foreach ($fields as $field) {
$fieldModel = new Vtiger_Field_Model();
$fieldModel->initialize($field);
$UITypeModel = $fieldModel->getUITypeModel();
if ($eventName == 'vtiger.entity.link.after') {
$UITypeModel->addValue($entityData['CRMEntity'], $entityData['sourceRecordId'], $entityData['destinationRecordId']);
} elseif ($eventName == 'vtiger.entity.unlink.after') {
$UITypeModel->removeValue(CRMEntity::getInstance($entityData['sourceModule']), $entityData['sourceRecordId'], $entityData['destinationRecordId']);
}
}
} else {
if ($eventName == 'vtiger.entity.aftersave.final') {
$db = PearDatabase::getInstance();
$moduleName = $entityData->getModuleName();
$modules = Vtiger_MultiReferenceValue_UIType::getRelatedModules($moduleName);
foreach ($modules as $module) {
$db->insert('s_yf_multireference', ['source_module' => $module, 'dest_module' => $moduleName, 'lastid' => $entityData->getId(), 'type' => 1]);
}
}
}
}
示例14: vt530_addDepedencyToVTWorkflowEventHandler
function vt530_addDepedencyToVTWorkflowEventHandler()
{
$db = PearDatabase::getInstance();
$dependentEventHandlers = array('VTEntityDelta');
$dependentEventHandlersJson = Zend_Json::encode($dependentEventHandlers);
ExecuteQuery("UPDATE vtiger_eventhandlers SET dependent_on='{$dependentEventHandlersJson}'\n\t\t\t\t\t\t\t\tWHERE event_name='vtiger.entity.aftersave' AND handler_class='VTWorkflowEventHandler'");
}
示例15: vtlib_handler
/**
* Invoked when special actions are performed on the module.
* @param String Module name
* @param String Event Type
*/
function vtlib_handler($moduleName, $eventType) {
if ($eventType == 'module.postinstall') {
$adb = PearDatabase::getInstance();
$otherSettingsBlock = $adb->pquery('SELECT * FROM vtiger_settings_blocks WHERE label=?', array('LBL_OTHER_SETTINGS'));
$otherSettingsBlockCount = $adb->num_rows($otherSettingsBlock);
if ($otherSettingsBlockCount > 0) {
$blockid = $adb->query_result($otherSettingsBlock, 0, 'blockid');
$sequenceResult = $adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_blocks WHERE blockid=", array($blockid));
if ($adb->num_rows($sequenceResult)) {
$sequence = $adb->query_result($sequenceResult, 0, 'sequence');
}
}
$fieldid = $adb->getUniqueID('vtiger_settings_field');
$adb->pquery("INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence, active)
VALUES(?,?,?,?,?,?,?,?)", array($fieldid, $blockid, 'VGS Duplicate Detector', '', 'VGSDuplicateDetector', 'index.php?module=VGSDuplicateDetector&view=IndexVGSDup&parent=Settings', $sequence++, 0));
} else if ($eventType == 'module.disabled') {
} else if ($eventType == 'module.preuninstall') {
$adb = PearDatabase::getInstance();
$adb->pquery("DELETE FROM vtiger_settings_field WHERE name=?", array('VGS Duplicate Detector'));
} else if ($eventType == 'module.preupdate') {
} else if ($eventType == 'module.postupdate') {
}
}