本文整理汇总了PHP中PearDatabase::getUniqueID方法的典型用法代码示例。如果您正苦于以下问题:PHP PearDatabase::getUniqueID方法的具体用法?PHP PearDatabase::getUniqueID怎么用?PHP PearDatabase::getUniqueID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PearDatabase
的用法示例。
在下文中一共展示了PearDatabase::getUniqueID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadAndSaveFile
/** Function to upload the file to the server and add the file details in the attachments table
* @param $id -- user id:: Type varchar
* @param $module -- module name:: Type varchar
* @param $file_details -- file details array:: Type array
*/
function uploadAndSaveFile($id, $module, $file_details)
{
$log = vglobal('log');
$log->debug("Entering into uploadAndSaveFile({$id},{$module},{$file_details}) method.");
$current_user = vglobal('current_user');
global $upload_badext;
$date_var = date('Y-m-d H:i:s');
//to get the owner id
$ownerid = $this->column_fields['assigned_user_id'];
if (!isset($ownerid) || $ownerid == '') {
$ownerid = $current_user->id;
}
$saveFile = 'true';
//only images are allowed for these modules
if ($module == 'Users') {
$saveFile = validateImageFile($file_details);
}
if ($saveFile == 'false') {
return;
}
$file = $file_details['name'];
$binFile = sanitizeUploadFileName($file, $upload_badext);
$filename = ltrim(basename(" " . $binFile));
//allowed filename like UTF-8 characters
$filetype = $file_details['type'];
$filesize = $file_details['size'];
$filetmp_name = $file_details['tmp_name'];
$current_id = $this->db->getUniqueID("vtiger_crmentity");
//get the file path inwhich folder we want to upload the file
$upload_file_path = decideFilePath($module);
//upload the file in server
$upload_status = move_uploaded_file($filetmp_name, $upload_file_path . $current_id . "_" . $binFile);
if ($saveFile == 'true') {
$sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?,?,?,?,?,?,?)";
$params1 = array($current_id, $current_user->id, $ownerid, $module . " Attachment", $this->column_fields['description'], $this->db->formatDate($date_var, true), $this->db->formatDate($date_var, true));
$this->db->pquery($sql1, $params1);
$sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?,?,?,?,?)";
$params2 = array($current_id, $filename, $this->column_fields['description'], $filetype, $upload_file_path);
$result = $this->db->pquery($sql2, $params2);
if ($id != '') {
$delquery = 'delete from vtiger_salesmanattachmentsrel where smid = ?';
$this->db->pquery($delquery, array($id));
}
$sql3 = 'insert into vtiger_salesmanattachmentsrel values(?,?)';
$this->db->pquery($sql3, array($id, $current_id));
//we should update the imagename in the users table
$this->db->pquery("update vtiger_users set imagename=? where id=?", array($filename, $id));
} else {
$log->debug("Skip the save attachment process.");
}
$log->debug("Exiting from uploadAndSaveFile({$id},{$module},{$file_details}) method.");
return;
}
示例2: migrate
function migrate($migrationInfo)
{
global $installationStrings;
$completed = false;
set_time_limit(0);
//ADDED TO AVOID UNEXPECTED TIME OUT WHILE MIGRATING
global $dbconfig;
require $migrationInfo['root_directory'] . '/config.inc.php';
$dbtype = $dbconfig['db_type'];
$host = $dbconfig['db_server'] . $dbconfig['db_port'];
$dbname = $dbconfig['db_name'];
$username = $dbconfig['db_username'];
$passwd = $dbconfig['db_password'];
global $adb, $migrationlog;
$adb = new PearDatabase($dbtype, $host, $dbname, $username, $passwd);
$query = " ALTER DATABASE " . $adb->escapeDbName($dbname) . " DEFAULT CHARACTER SET utf8";
$adb->query($query);
$source_directory = $migrationInfo['source_directory'];
if (file_exists($source_directory . 'user_privileges/CustomInvoiceNo.php')) {
require_once $source_directory . 'user_privileges/CustomInvoiceNo.php';
}
$migrationlog =& LoggerManager::getLogger('MIGRATION');
if (isset($migrationInfo['old_version'])) {
$source_version = $migrationInfo['old_version'];
}
if (!isset($source_version) || empty($source_version)) {
//If source version is not set then we cannot proceed
echo "<br> " . $installationStrings['LBL_SOURCE_VERSION_NOT_SET'];
exit;
}
$reach = 0;
include $migrationInfo['root_directory'] . "/modules/Migration/versions.php";
foreach ($versions as $version => $label) {
if ($version == $source_version || $reach == 1) {
$reach = 1;
$temp[] = $version;
}
}
$temp[] = $current_version;
global $adb, $dbname;
$_SESSION['adodb_current_object'] = $adb;
@ini_set('zlib.output_compression', 0);
@ini_set('output_buffering', 'off');
ob_implicit_flush(true);
echo '<table width="98%" border="1px" cellpadding="3" cellspacing="0" height="100%">';
if (is_array($_SESSION['migration_info']['user_messages'])) {
foreach ($_SESSION['migration_info']['user_messages'] as $infoMap) {
echo "<tr><td>" . $infoMap['status'] . "</td><td>" . $infoMap['msg'] . "</td></tr>";
}
}
echo "<tr><td colspan='2'><b>{$installationStrings['LBL_GOING_TO_APPLY_DB_CHANGES']}...</b></td></tr>";
for ($patch_count = 0; $patch_count < count($temp); $patch_count++) {
//Here we have to include all the files (all db differences for each release will be included)
$filename = "modules/Migration/DBChanges/" . $temp[$patch_count] . "_to_" . $temp[$patch_count + 1] . ".php";
$empty_tag = "<tr><td colspan='2'> </td></tr>";
$start_tag = "<tr><td colspan='2'><b><font color='red'> ";
$end_tag = "</font></b></td></tr>";
if (is_file($filename)) {
echo $empty_tag . $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_STARTS'] . "." . $end_tag;
include $filename;
//include the file which contains the corresponding db changes
echo $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_ENDS'] . "." . $end_tag;
}
}
/* Install Vtlib Compliant Modules */
Common_Install_Wizard_Utils::installMandatoryModules();
Migration_Utils::installOptionalModules($migrationInfo['selected_optional_modules'], $migrationInfo['source_directory'], $migrationInfo['root_directory']);
Migration_utils::copyLanguageFiles($migrationInfo['source_directory'], $migrationInfo['root_directory']);
//Here we have to update the version in table. so that when we do migration next time we will get the version
$res = $adb->query('SELECT * FROM vtiger_version');
global $vtiger_current_version;
require $migrationInfo['root_directory'] . '/vtigerversion.php';
if ($adb->num_rows($res)) {
$res = ExecuteQuery("UPDATE vtiger_version SET old_version='{$versions[$source_version]}',current_version='{$vtiger_current_version}'");
$completed = true;
} else {
ExecuteQuery("INSERT INTO vtiger_version (id, old_version, current_version) values (" . $adb->getUniqueID('vtiger_version') . ", '{$versions[$source_version]}', '{$vtiger_current_version}');");
$completed = true;
}
echo '</table><br><br>';
create_tab_data_file();
create_parenttab_data_file();
return $completed;
}
示例3: process
function process()
{
set_time_limit(0);
//ADDED TO AVOID UNEXPECTED TIME OUT WHILE MIGRATING
$returnValue = vtiger_DatabaseMigration::initMigration();
if ($returnValue !== true) {
echo $returnValue;
return false;
}
global $dbconfig;
require dirname(__FILE__) . '/config.inc.php';
$dbtype = $dbconfig['db_type'];
$host = $dbconfig['db_server'] . $dbconfig['db_port'];
$dbname = $dbconfig['db_name'];
$username = $dbconfig['db_username'];
$passwd = $dbconfig['db_password'];
global $adb, $migrationlog;
$adb = new PearDatabase($dbtype, $host, $dbname, $username, $passwd);
// Why do we do this here? We shouldn't alter here if its not in UTF8.
$query = " ALTER DATABASE " . $dbname . " DEFAULT CHARACTER SET utf8";
$adb->query($query);
$source_directory = $_SESSION['migration_info']['source_directory'];
if (file_exists($source_directory . 'user_privileges/CustomInvoiceNo.php')) {
require_once $source_directory . 'user_privileges/CustomInvoiceNo.php';
}
$versions_non_utf8 = array("50", "501", "502", "503rc2", "503", "504rc");
$php_max_execution_time = 0;
$migrationlog =& LoggerManager::getLogger('MIGRATION');
if (isset($_SESSION['migration_info']['old_version'])) {
$source_version = $_SESSION['migration_info']['old_version'];
}
if (!isset($source_version) || empty($source_version)) {
//If source version is not set then we cannot proceed
echo "<br> Source Version is not set. Please check vtigerversion.php and contiune the Patch Process";
exit;
}
$reach = 0;
include dirname(__FILE__) . "/modules/Migration/versions.php";
foreach ($versions as $version => $label) {
if ($version == $source_version || $reach == 1) {
$reach = 1;
$temp[] = $version;
}
}
$temp[] = $current_version;
global $adb, $dbname;
$_SESSION['adodb_current_object'] = $adb;
@ini_set('zlib.output_compression', 0);
@ini_set('output_buffering', 'off');
ob_implicit_flush(true);
echo '<table width="98%" border="1px" cellpadding="3" cellspacing="0" height="100%">';
echo "<tr><td colspan='2'><b>Going to apply the Database Changes...</b></td><tr>";
for ($patch_count = 0; $patch_count < count($temp); $patch_count++) {
//Here we have to include all the files (all db differences for each release will be included)
$filename = "modules/Migration/DBChanges/" . $temp[$patch_count] . "_to_" . $temp[$patch_count + 1] . ".php";
$empty_tag = "<tr><td colspan='2'> </td></tr>";
$start_tag = "<tr><td colspan='2'><b><font color='red'> ";
$end_tag = "</font></b></td></tr>";
if (is_file($filename)) {
echo $empty_tag . $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " Database changes -- Starts." . $end_tag;
include $filename;
//include the file which contains the corresponding db changes
echo $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " Database changes -- Ends." . $end_tag;
}
}
//Here we have to update the version in table. so that when we do migration next time we will get the version
$res = $adb->query('SELECT * FROM vtiger_version');
global $vtiger_current_version;
require dirname(__FILE__) . '/vtigerversion.php';
if ($adb->num_rows($res)) {
$res = ExecuteQuery("UPDATE vtiger_version SET old_version='{$versions[$source_version]}',current_version='{$vtiger_current_version}'");
$completed = true;
} else {
ExecuteQuery("INSERT INTO vtiger_version (id, old_version, current_version) values (" . $adb->getUniqueID('vtiger_version') . ", '{$versions[$source_version]}', '{$vtiger_current_version}');");
$completed = true;
}
echo '</table><br><br>';
if ($completed == true) {
echo "<script type='text/javascript'>window.parent.Migration_Complete();</script>";
}
create_tab_data_file();
create_parenttab_data_file();
if ($completed == true) {
return true;
}
}