Now is possible upgrade the data in the tables, DASHLET is the first
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* class.database_mssql.php
|
||||
* @package gulliver.system
|
||||
* @package gulliver.system
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
@@ -31,9 +31,9 @@
|
||||
G::LoadSystem('database_base');
|
||||
|
||||
class database extends database_base {
|
||||
|
||||
|
||||
public $iFetchType = MSSQL_ASSOC;
|
||||
|
||||
|
||||
public function __construct($sType = DB_ADAPTER, $sServer = DB_HOST, $sUser = DB_USER, $sPass = DB_PASS, $sDataBase = DB_NAME) {
|
||||
$this->sType = $sType;
|
||||
$this->sServer = $sServer;
|
||||
@@ -45,19 +45,19 @@ class database extends database_base {
|
||||
$this->sQuoteCharacterBegin = '[';
|
||||
$this->sQuoteCharacterEnd = ']';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function generateCreateTableSQL($sTable, $aColumns) {
|
||||
$sKeys = '';
|
||||
$sSQL = 'CREATE TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '(';
|
||||
|
||||
|
||||
foreach ($aColumns as $sColumnName => $aParameters) {
|
||||
if ($sColumnName != 'INDEXES') {
|
||||
|
||||
|
||||
if ( $sColumnName != '' && isset($aParameters['Type']) && $aParameters['Type'] != '' ){
|
||||
$sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
||||
|
||||
|
||||
if ( isset($aParameters['Null']) && $aParameters['Null'] == 'YES') {
|
||||
$sSQL .= ' NULL';
|
||||
} else {
|
||||
@@ -66,11 +66,11 @@ class database extends database_base {
|
||||
if ( isset($aParameters['Key']) && $aParameters['Key'] == 'PRI') {
|
||||
$sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ',';
|
||||
}
|
||||
|
||||
|
||||
if ( isset($aParameters['Default']) && $aParameters['Default'] != '' ) {
|
||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||
}
|
||||
|
||||
|
||||
$sSQL .= ',';
|
||||
}
|
||||
}
|
||||
@@ -80,22 +80,22 @@ class database extends database_base {
|
||||
$sSQL .= ',PRIMARY KEY(' . substr($sKeys, 0, -1) . ')';
|
||||
}
|
||||
$sSQL .= ')' . $this->sEndLine;
|
||||
|
||||
|
||||
return $sSQL;
|
||||
}
|
||||
|
||||
|
||||
public function generateDropTableSQL($sTable) {
|
||||
return 'DROP TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . $this->sEndLine;
|
||||
}
|
||||
|
||||
public function generateDropColumnSQL($sTable, $sColumn) {
|
||||
// SQL Server first should remove the restriction before the Elimination of the field
|
||||
// SQL Server first should remove the restriction before the Elimination of the field
|
||||
$oConstraint = $this->dropFieldConstraint($sTable, $sColumn);
|
||||
$sSQL = 'ALTER TABLE ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter .
|
||||
' DROP COLUMN ' . $this->sQuoteCharacter . $sColumn . $this->sQuoteCharacter . $this->sEndLine;
|
||||
return $sSQL;
|
||||
}
|
||||
|
||||
|
||||
public function generateAddColumnSQL($sTable, $sColumn, $aParameters) {
|
||||
if ( isset($aParameters['Type']) && isset($aParameters['Null']) ) {
|
||||
$sDefault = "";
|
||||
@@ -105,15 +105,15 @@ class database extends database_base {
|
||||
$sType = substr($sType, 0, strpos($sType,'('));
|
||||
}
|
||||
switch($sType) {
|
||||
case 'VARCHAR' :
|
||||
case 'TEXT' : $sDefault = " DEFAULT '' ";
|
||||
case 'VARCHAR' :
|
||||
case 'TEXT' : $sDefault = " DEFAULT '' ";
|
||||
break;
|
||||
case 'DATE' : $sDataType = " CHAR(19) ";
|
||||
$sDefault = " DEFAULT '0000-00-00' "; // The date data type to use char (19)
|
||||
break;
|
||||
case 'INT' :
|
||||
case 'INT' :
|
||||
case 'FLOAT' : $sDataType = $sType;
|
||||
$sDefault = " DEFAULT 0 ";
|
||||
$sDefault = " DEFAULT 0 ";
|
||||
break;
|
||||
}
|
||||
$sSQL = "ALTER TABLE " . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter .
|
||||
@@ -124,7 +124,7 @@ class database extends database_base {
|
||||
}
|
||||
else {
|
||||
$sSQL .= " NOT NULL " . $sDefault;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
/*if ($aParameters['Key'] == 'PRI') {
|
||||
@@ -182,7 +182,7 @@ class database extends database_base {
|
||||
if ( trim($aParameters['Default'] == '') && $aParameters['Type'] == 'datetime' ) {
|
||||
//do nothing
|
||||
}
|
||||
else
|
||||
else
|
||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||
//}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ class database extends database_base {
|
||||
$sSQL .= $this->sEndLine;
|
||||
return $sSQL;
|
||||
}
|
||||
|
||||
|
||||
public function generateGetPrimaryKeysSQL($sTable) {
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
@@ -206,7 +206,7 @@ class database extends database_base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get primary key
|
||||
* @parameter string $sTable
|
||||
* @return string $sPrimaryKey
|
||||
@@ -221,19 +221,19 @@ class database extends database_base {
|
||||
" AND CONSTRAINT_TYPE = 'PRIMARY KEY' " .
|
||||
" AND c.TABLE_NAME = pk.TABLE_NAME " .
|
||||
" AND c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME ";
|
||||
$oPrimaryKey = $this->executeQuery($sSQL);
|
||||
$oPrimaryKey = $this->executeQuery($sSQL);
|
||||
$aPrimaryKey = mssql_fetch_array($oPrimaryKey);
|
||||
mssql_free_result($oPrimaryKey);
|
||||
return $aPrimaryKey[0];
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Get Field Constraint
|
||||
* @parameter string $sTable
|
||||
* @parameter string $sField
|
||||
* @parameter string $sField
|
||||
* @return string $sFieldConstraint
|
||||
*/
|
||||
public function getFieldConstraint($sTable, $sField)
|
||||
@@ -245,21 +245,21 @@ class database extends database_base {
|
||||
" where a.xtype = 'D' " .
|
||||
" and a.parent_obj = (select id from sysobjects where xtype = 'U' and name = '" . trim($sTable) . "') " .
|
||||
" and b.name = '" . trim($sField) . "' ";
|
||||
|
||||
$oFieldConstraint = $this->executeQuery($sSQL);
|
||||
|
||||
$oFieldConstraint = $this->executeQuery($sSQL);
|
||||
$aFieldConstraint = mssql_fetch_array($oFieldConstraint);
|
||||
mssql_free_result($oFieldConstraint);
|
||||
return $aFieldConstraint[0];
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* drop Field Constraint
|
||||
* @parameter string $sTable
|
||||
* @parameter string $sField
|
||||
* @parameter string $sField
|
||||
* @return object $oFieldConstraint
|
||||
*/
|
||||
public function dropFieldConstraint($sTable, $sField)
|
||||
@@ -267,11 +267,11 @@ class database extends database_base {
|
||||
try {
|
||||
$sConstraint = $this->getFieldConstraint($sTable, $sField);
|
||||
$sSQL = "ALTER TABLE " . $sTable . " DROP CONSTRAINT " . $sConstraint . $this->sEndLine ;
|
||||
$oFieldConstraint = $this->executeQuery($sSQL);
|
||||
$oFieldConstraint = $this->executeQuery($sSQL);
|
||||
return $oFieldConstraint;
|
||||
} catch (Exception $oException) {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ class database extends database_base {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function generateAddPrimaryKeysSQL($sTable, $aPrimaryKeys) {
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
@@ -306,7 +306,7 @@ class database extends database_base {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function generateDropKeySQL($sTable, $sIndexName) {
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
@@ -341,15 +341,15 @@ class database extends database_base {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function generateShowTablesSQL() {
|
||||
return 'SHOW TABLES' . $this->sEndLine;
|
||||
}
|
||||
|
||||
|
||||
public function generateShowTablesLikeSQL($sTable) {
|
||||
return "SHOW TABLES LIKE '" . $sTable . "'" . $this->sEndLine;
|
||||
}
|
||||
|
||||
|
||||
public function generateDescTableSQL($sTable) {
|
||||
try {
|
||||
if ($sTable == '') {
|
||||
@@ -361,14 +361,14 @@ class database extends database_base {
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function generateTableIndexSQL($sTable) {
|
||||
return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " " . $this->sEndLine;
|
||||
//return 'SHOW INDEX FROM ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . " WHERE Key_name <> 'PRIMARY'" . $this->sEndLine;
|
||||
}
|
||||
|
||||
public function isConnected() {
|
||||
if ( !$this->oConnection )
|
||||
public function isConnected() {
|
||||
if ( !$this->oConnection )
|
||||
return false;
|
||||
return $this->executeQuery( 'USE ' . $this->sDataBase );
|
||||
}
|
||||
@@ -387,13 +387,13 @@ class database extends database_base {
|
||||
fclose ( $fp );
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
catch (Exception $oException) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function executeQuery($sQuery) {
|
||||
$this->logQuery( $sQuery);
|
||||
|
||||
|
||||
try {
|
||||
if ($this->oConnection) {
|
||||
@mssql_select_db($this->sDataBase);
|
||||
@@ -404,25 +404,91 @@ class database extends database_base {
|
||||
throw new Exception('invalid connection to database ' . $this->sDataBase );
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
catch (Exception $oException) {
|
||||
$this->logQuery( $oException->getMessage() );
|
||||
throw $oException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function countResults($oDataset) {
|
||||
return @mssql_num_rows($oDataset);
|
||||
}
|
||||
|
||||
|
||||
public function getRegistry($oDataset) {
|
||||
return @mssql_fetch_array($oDataset, $this->iFetchType);
|
||||
}
|
||||
|
||||
|
||||
public function close() {
|
||||
@mssql_close($this->oConnection);
|
||||
}
|
||||
|
||||
|
||||
public function generateInsertSQL($table, $data) {
|
||||
$fields = array();
|
||||
$values = array();
|
||||
foreach ($data as $field) {
|
||||
$fields[] = $field['field'];
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$values[] = "'" . addslashes($field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$values[] = addslashes($field['value']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$fields = array_map(array($this, 'putQuotes'), $fields);
|
||||
$sql = sprintf("INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes($table), implode(', ', $fields), implode(', ', $values));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateUpdateSQL($table, $keys, $data) {
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$fields[] = $this->putQuotes($field['field']) . " = '" . addslashes($field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$fields[] = $this->putQuotes($field['field']) . " = " . addslashes($field['value']);
|
||||
break;
|
||||
}
|
||||
if (in_array($field['field'], $keys)) {
|
||||
$where[] = $fields[count($fields) - 1];
|
||||
}
|
||||
}
|
||||
$sql = sprintf("UPDATE %s SET %s WHERE %s", $this->putQuotes($table), implode(', ', $fields), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateDeleteSQL($table, $keys, $data) {
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
if (in_array($field['field'], $keys)) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$where[] = $this->putQuotes($field['field']) . " = '" . addslashes($field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$where[] = $this->putQuotes($field['field']) . " = " . addslashes($field['value']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = sprintf("DELETE FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
private function putQuotes($element) {
|
||||
return $this->sQuoteCharacterBegin . $element . $this->sQuoteCharacterEnd;
|
||||
}
|
||||
|
||||
/*=================================================================================================*/
|
||||
/**
|
||||
@@ -433,7 +499,7 @@ class database extends database_base {
|
||||
* date 2010-08-04
|
||||
*
|
||||
* @return string $sConcat
|
||||
*/
|
||||
*/
|
||||
function concatString()
|
||||
{
|
||||
$nums = func_num_args();
|
||||
@@ -449,7 +515,7 @@ class database extends database_base {
|
||||
return $sConcat;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* query functions for class class.case.php
|
||||
*
|
||||
*/
|
||||
@@ -460,9 +526,9 @@ class database extends database_base {
|
||||
* @author Hector Cortez <hector@gmail.com>
|
||||
* date 2010-08-04
|
||||
*
|
||||
* @return string $sCompare
|
||||
*/
|
||||
function getCaseWhen($compareValue, $trueResult, $falseResult)
|
||||
* @return string $sCompare
|
||||
*/
|
||||
function getCaseWhen($compareValue, $trueResult, $falseResult)
|
||||
{
|
||||
$sCompare = " CASE WHEN " . $compareValue . " THEN " . $trueResult . " ELSE " . $falseResult . " END ";
|
||||
return $sCompare;
|
||||
@@ -470,7 +536,7 @@ class database extends database_base {
|
||||
|
||||
/**
|
||||
* Generates a string equivalent to create table ObjectPermission
|
||||
*
|
||||
*
|
||||
* class.case.php
|
||||
* function verifyTable()
|
||||
*
|
||||
@@ -479,28 +545,28 @@ class database extends database_base {
|
||||
function createTableObjectPermission()
|
||||
{
|
||||
$sql = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='OBJECT_PERMISSION' AND xtype='U')
|
||||
CREATE TABLE OBJECT_PERMISSION (
|
||||
OP_UID varchar(32) NOT NULL,
|
||||
PRO_UID varchar(32) NOT NULL,
|
||||
TAS_UID varchar(32) NOT NULL,
|
||||
USR_UID varchar(32) NOT NULL,
|
||||
OP_USER_RELATION int NOT NULL default '1',
|
||||
OP_TASK_SOURCE varchar(32) NOT NULL,
|
||||
OP_PARTICIPATE int NOT NULL default '1',
|
||||
OP_OBJ_TYPE varchar(15) NOT NULL default 'ANY',
|
||||
OP_OBJ_UID varchar(32) NOT NULL,
|
||||
OP_ACTION varchar(10) NOT NULL default 'VIEW',
|
||||
CREATE TABLE OBJECT_PERMISSION (
|
||||
OP_UID varchar(32) NOT NULL,
|
||||
PRO_UID varchar(32) NOT NULL,
|
||||
TAS_UID varchar(32) NOT NULL,
|
||||
USR_UID varchar(32) NOT NULL,
|
||||
OP_USER_RELATION int NOT NULL default '1',
|
||||
OP_TASK_SOURCE varchar(32) NOT NULL,
|
||||
OP_PARTICIPATE int NOT NULL default '1',
|
||||
OP_OBJ_TYPE varchar(15) NOT NULL default 'ANY',
|
||||
OP_OBJ_UID varchar(32) NOT NULL,
|
||||
OP_ACTION varchar(10) NOT NULL default 'VIEW',
|
||||
CONSTRAINT PK_PRO_UID PRIMARY KEY CLUSTERED (PRO_UID, TAS_UID,USR_UID, OP_TASK_SOURCE, OP_OBJ_UID) )";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
}
|
||||
|
||||
/*
|
||||
* query functions for class class.report.php
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport4()
|
||||
*
|
||||
@@ -508,10 +574,10 @@ class database extends database_base {
|
||||
*/
|
||||
function getSelectReport4()
|
||||
{
|
||||
|
||||
|
||||
$sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] ";
|
||||
$sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME ";
|
||||
|
||||
|
||||
$sql = "SELECT " . $sqlConcat . ", " .
|
||||
" COUNT(*) AS CANTCASES,
|
||||
MIN(AD.DEL_DURATION) AS MIN,
|
||||
@@ -523,20 +589,20 @@ class database extends database_base {
|
||||
LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER)
|
||||
WHERE A.APP_UID<>''
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
|
||||
return $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport4_filter()
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
function getSelectReport4Filter($var)
|
||||
function getSelectReport4Filter($var)
|
||||
{
|
||||
$sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] ";
|
||||
$sqlGroupBy = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME ";
|
||||
@@ -554,12 +620,12 @@ class database extends database_base {
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
return $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport5()
|
||||
*
|
||||
@@ -582,20 +648,20 @@ class database extends database_base {
|
||||
LEFT JOIN USERS AS U ON(U.USR_UID = AD.USR_UID)
|
||||
WHERE AD.APP_UID<>'' AND AD.DEL_FINISH_DATE IS NULL
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
|
||||
return $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport5_filter()
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
function getSelectReport5Filter($var)
|
||||
function getSelectReport5Filter($var)
|
||||
{
|
||||
|
||||
$sqlConcat = " U.USR_LASTNAME + ' ' + USR_FIRSTNAME AS [USER] ";
|
||||
@@ -615,19 +681,19 @@ class database extends database_base {
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* query functions for class class.net.php
|
||||
*
|
||||
*/
|
||||
function getServerVersion($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename)
|
||||
{
|
||||
|
||||
|
||||
if(strlen(trim($dbIP))<=0)
|
||||
$dbIP = DB_HOST;
|
||||
if($link = @mssql_connect($dbIP, $dbUser, $dbPasswd)){
|
||||
@mssql_select_db( DB_NAME, $link );
|
||||
$oResult = @mssql_query("select substring(@@version, 21, 6) + ' (' + CAST(SERVERPROPERTY ('productlevel') as varchar(10)) + ') ' + CAST(SERVERPROPERTY('productversion') AS VARCHAR(15)) + ' ' + CAST(SERVERPROPERTY ('edition') AS VARCHAR(25)) as version; ", $link);
|
||||
$oResult = @mssql_query("select substring(@@version, 21, 6) + ' (' + CAST(SERVERPROPERTY ('productlevel') as varchar(10)) + ') ' + CAST(SERVERPROPERTY('productversion') AS VARCHAR(15)) + ' ' + CAST(SERVERPROPERTY ('edition') AS VARCHAR(25)) as version; ", $link);
|
||||
$aResult = @mssql_fetch_array($oResult);
|
||||
@mssql_free_result($oResult);
|
||||
$v = $aResult[0];
|
||||
@@ -635,11 +701,11 @@ class database extends database_base {
|
||||
throw new Exception(@mssql_error($link));
|
||||
}
|
||||
return (isset($v))?$v:'none';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/*
|
||||
* query functions for class class.net.php
|
||||
*
|
||||
*/
|
||||
@@ -648,9 +714,9 @@ class database extends database_base {
|
||||
$sql = "IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='" . $sTableName . "' AND xtype='U') " .
|
||||
"DROP TABLE ['" . $sTableName . "']";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getTableDescription($sTableName)
|
||||
{
|
||||
$sql = " select column_name as Field,
|
||||
@@ -673,7 +739,7 @@ class database extends database_base {
|
||||
" Order by Ordinal_Position asc ";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
function getFieldNull()
|
||||
{
|
||||
$fieldName = "AsNull";
|
||||
@@ -696,10 +762,10 @@ class database extends database_base {
|
||||
$oConnection = mssql_connect(DB_HOST, DB_USER, DB_PASS);
|
||||
mssql_select_db(DB_NAME);
|
||||
$oDataset = mssql_query('SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false);
|
||||
|
||||
|
||||
return $bExists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* It is part of class.pagedTable.php
|
||||
*/
|
||||
@@ -708,11 +774,11 @@ class database extends database_base {
|
||||
$sql = "";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determining the existence of a table
|
||||
*/
|
||||
function tableExists ($table, $db) {
|
||||
function tableExists ($table, $db) {
|
||||
$sql = "SELECT * FROM sysobjects WHERE name='" . $table . "' AND type='u'";
|
||||
$bExists = true;
|
||||
$oConnection = mssql_connect(DB_HOST, DB_USER, DB_PASS);
|
||||
@@ -720,5 +786,5 @@ class database extends database_base {
|
||||
$oDataset = mssql_query($sql) || ($bExists = false);
|
||||
return $bExists;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* class.database_mysql.php
|
||||
* @package gulliver.system
|
||||
* @package gulliver.system
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
@@ -31,7 +31,7 @@
|
||||
G::LoadSystem('database_base');
|
||||
|
||||
class database extends database_base {
|
||||
|
||||
|
||||
public $iFetchType = MYSQL_ASSOC;
|
||||
|
||||
/**
|
||||
@@ -61,13 +61,13 @@ class database extends database_base {
|
||||
public function generateCreateTableSQL($sTable, $aColumns) {
|
||||
$sKeys = '';
|
||||
$sSQL = 'CREATE TABLE IF NOT EXISTS ' . $this->sQuoteCharacter . $sTable . $this->sQuoteCharacter . '(';
|
||||
|
||||
|
||||
foreach ($aColumns as $sColumnName => $aParameters) {
|
||||
if ($sColumnName != 'INDEXES') {
|
||||
|
||||
|
||||
if ( $sColumnName != '' && isset($aParameters['Type']) && $aParameters['Type'] != '' ){
|
||||
$sSQL .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ' ' . $aParameters['Type'];
|
||||
|
||||
|
||||
if ( isset($aParameters['Null']) && $aParameters['Null'] == 'YES') {
|
||||
$sSQL .= ' NULL';
|
||||
} else {
|
||||
@@ -76,11 +76,11 @@ class database extends database_base {
|
||||
if ( isset($aParameters['Key']) && $aParameters['Key'] == 'PRI') {
|
||||
$sKeys .= $this->sQuoteCharacter . $sColumnName . $this->sQuoteCharacter . ',';
|
||||
}
|
||||
|
||||
|
||||
if ( isset($aParameters['Default']) && $aParameters['Default'] != '' ) {
|
||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||
}
|
||||
|
||||
|
||||
$sSQL .= ',';
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ class database extends database_base {
|
||||
$sSQL .= ',PRIMARY KEY(' . substr($sKeys, 0, -1) . ')';
|
||||
}
|
||||
$sSQL .= ')' . $this->sEndLine;
|
||||
|
||||
|
||||
return $sSQL;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class database extends database_base {
|
||||
if ( trim($aParameters['Default'] == '') && $aParameters['Type'] == 'datetime' ) {
|
||||
//do nothing
|
||||
}
|
||||
else
|
||||
else
|
||||
$sSQL .= " DEFAULT '" . $aParameters['Default'] . "'";
|
||||
//}
|
||||
}
|
||||
@@ -208,7 +208,7 @@ class database extends database_base {
|
||||
$sSQL .= $this->sEndLine;
|
||||
return $sSQL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate and get the primary key in a sentence
|
||||
* @param $sTable table name
|
||||
@@ -295,7 +295,7 @@ class database extends database_base {
|
||||
* @param $aKeys array of keys
|
||||
* @return sql sentence
|
||||
*/
|
||||
|
||||
|
||||
public function generateAddKeysSQL($sTable, $indexName, $aKeys) {
|
||||
try {
|
||||
$indexType = 'INDEX';
|
||||
@@ -363,8 +363,8 @@ class database extends database_base {
|
||||
* execute a sentence to check if there is connection
|
||||
* @return void
|
||||
*/
|
||||
public function isConnected() {
|
||||
if ( !$this->oConnection )
|
||||
public function isConnected() {
|
||||
if ( !$this->oConnection )
|
||||
return false;
|
||||
return $this->executeQuery( 'USE ' . $this->sDataBase );
|
||||
}
|
||||
@@ -394,9 +394,9 @@ class database extends database_base {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
catch (Exception $oException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* execute a sql query
|
||||
@@ -405,7 +405,7 @@ class database extends database_base {
|
||||
*/
|
||||
public function executeQuery($sQuery) {
|
||||
$this->logQuery( $sQuery);
|
||||
|
||||
|
||||
try {
|
||||
if ($this->oConnection) {
|
||||
@mysql_select_db($this->sDataBase);
|
||||
@@ -416,7 +416,7 @@ class database extends database_base {
|
||||
throw new Exception('invalid connection to database ' . $this->sDataBase );
|
||||
}
|
||||
}
|
||||
catch (Exception $oException) {
|
||||
catch (Exception $oException) {
|
||||
$this->logQuery( $oException->getMessage() );
|
||||
throw $oException;
|
||||
}
|
||||
@@ -447,8 +447,96 @@ class database extends database_base {
|
||||
public function close() {
|
||||
@mysql_close($this->oConnection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function generateInsertSQL($table, $data) {
|
||||
$fields = array();
|
||||
$values = array();
|
||||
foreach ($data as $field) {
|
||||
$fields[] = $field['field'];
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$values[] = "'" . mysql_real_escape_string($field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$values[] = mysql_real_escape_string($field['value']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$fields = array_map(array($this, 'putQuotes'), $fields);
|
||||
$sql = sprintf("INSERT INTO %s (%s) VALUES (%s)", $this->putQuotes($table), implode(', ', $fields), implode(', ', $values));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateUpdateSQL($table, $keys, $data) {
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$fields[] = $this->putQuotes($field['field']) . " = '" . mysql_real_escape_string($field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$fields[] = $this->putQuotes($field['field']) . " = " . mysql_real_escape_string($field['value']);
|
||||
break;
|
||||
}
|
||||
if (in_array($field['field'], $keys)) {
|
||||
$where[] = $fields[count($fields) - 1];
|
||||
}
|
||||
}
|
||||
$sql = sprintf("UPDATE %s SET %s WHERE %s", $this->putQuotes($table), implode(', ', $fields), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateDeleteSQL($table, $keys, $data) {
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
if (in_array($field['field'], $keys)) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$where[] = $this->putQuotes($field['field']) . " = '" . mysql_real_escape_string($field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$where[] = $this->putQuotes($field['field']) . " = " . mysql_real_escape_string($field['value']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = sprintf("DELETE FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function generateSelectSQL($table, $keys, $data) {
|
||||
$fields = array();
|
||||
$where = array();
|
||||
foreach ($data as $field) {
|
||||
if (in_array($field['field'], $keys)) {
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
case 'date':
|
||||
$where[] = $this->putQuotes($field['field']) . " = '" . mysql_real_escape_string($field['value']) . "'";
|
||||
break;
|
||||
case 'int':
|
||||
default:
|
||||
$where[] = $this->putQuotes($field['field']) . " = " . mysql_real_escape_string($field['value']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = sprintf("SELECT * FROM %s WHERE %s", $this->putQuotes($table), implode(', ', $where));
|
||||
return $sql;
|
||||
}
|
||||
|
||||
private function putQuotes($element) {
|
||||
return $this->sQuoteCharacter . $element . $this->sQuoteCharacter;
|
||||
}
|
||||
|
||||
/*=================================================================================================*/
|
||||
/**
|
||||
* concatString
|
||||
@@ -458,7 +546,7 @@ class database extends database_base {
|
||||
* date 2010-08-04
|
||||
*
|
||||
* @return string $sConcat
|
||||
*/
|
||||
*/
|
||||
function concatString()
|
||||
{
|
||||
$nums = func_num_args();
|
||||
@@ -475,10 +563,10 @@ class database extends database_base {
|
||||
$sConcat .= ")";
|
||||
|
||||
return $sConcat;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* query functions for class class.case.php
|
||||
*
|
||||
*/
|
||||
@@ -489,18 +577,18 @@ class database extends database_base {
|
||||
* author Hector Cortez <hector@gmail.com>
|
||||
* date 2010-08-04
|
||||
*
|
||||
* @return string $sCompare
|
||||
*/
|
||||
function getCaseWhen($compareValue, $trueResult, $falseResult)
|
||||
* @return string $sCompare
|
||||
*/
|
||||
function getCaseWhen($compareValue, $trueResult, $falseResult)
|
||||
{
|
||||
$sCompare = "IF(" . $compareValue . ", " . $trueResult . ", " . $falseResult . ") ";
|
||||
return $sCompare;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string equivalent to create table ObjectPermission
|
||||
*
|
||||
*
|
||||
* class.case.php
|
||||
* function verifyTable()
|
||||
*
|
||||
@@ -522,15 +610,15 @@ class database extends database_base {
|
||||
KEY `PRO_UID` (`PRO_UID`,`TAS_UID`,`USR_UID`,`OP_TASK_SOURCE`,`OP_OBJ_UID`)
|
||||
)ENGINE=MyISAM DEFAULT CHARSET=latin1;";
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
}
|
||||
|
||||
/*
|
||||
* query functions for class class.report.php
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport4()
|
||||
*
|
||||
@@ -538,10 +626,10 @@ class database extends database_base {
|
||||
*/
|
||||
function getSelectReport4()
|
||||
{
|
||||
|
||||
|
||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||
$sqlGroupBy = " USER ";
|
||||
|
||||
|
||||
$sql = "SELECT " . $sqlConcat . ", " .
|
||||
" COUNT(*) AS CANTCASES,
|
||||
MIN(AD.DEL_DURATION) AS MIN,
|
||||
@@ -553,20 +641,20 @@ class database extends database_base {
|
||||
LEFT JOIN USERS AS U ON(U.USR_UID = A.APP_INIT_USER)
|
||||
WHERE A.APP_UID<>''
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
|
||||
return $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport4_filter()
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
function getSelectReport4Filter($var)
|
||||
function getSelectReport4Filter($var)
|
||||
{
|
||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||
$sqlGroupBy = " USER ";
|
||||
@@ -584,12 +672,12 @@ class database extends database_base {
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
return $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport5()
|
||||
*
|
||||
@@ -611,20 +699,20 @@ class database extends database_base {
|
||||
LEFT JOIN USERS AS U ON(U.USR_UID = AD.USR_UID)
|
||||
WHERE AD.APP_UID<>'' AND AD.DEL_FINISH_DATE IS NULL
|
||||
GROUP BY " . $sqlGroupBy;
|
||||
|
||||
|
||||
return $sql;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a string query
|
||||
*
|
||||
*
|
||||
* class.report.php
|
||||
* function generatedReport5_filter()
|
||||
*
|
||||
* @return string $sql
|
||||
*/
|
||||
function getSelectReport5Filter($var)
|
||||
function getSelectReport5Filter($var)
|
||||
{
|
||||
|
||||
$sqlConcat = " CONCAT(U.USR_LASTNAME,' ',USR_FIRSTNAME) AS USER ";
|
||||
@@ -644,25 +732,25 @@ class database extends database_base {
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* query functions for class class.net.php
|
||||
*
|
||||
*/
|
||||
function getServerVersion($driver, $dbIP, $dbPort, $dbUser, $dbPasswd, $dbSourcename)
|
||||
{
|
||||
|
||||
|
||||
if($link = @mysql_connect($dbIP, $dbUser, $dbPasswd)){
|
||||
$v = @mysql_get_server_info();
|
||||
} else {
|
||||
throw new Exception(@mysql_error($link));
|
||||
}
|
||||
return (isset($v))?$v:'none';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/*
|
||||
* query functions for class class.net.php, class.reportTables.php
|
||||
*
|
||||
*/
|
||||
@@ -670,15 +758,15 @@ class database extends database_base {
|
||||
{
|
||||
$sql = 'DROP TABLE IF EXISTS `' . $sTableName . '`';
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getTableDescription($sTableName)
|
||||
{
|
||||
$sql = "DESC ".$sTableName;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
function getFieldNull()
|
||||
{
|
||||
$fieldName = "Null";
|
||||
@@ -701,7 +789,7 @@ class database extends database_base {
|
||||
$oConnection = mysql_connect(DB_HOST, DB_USER, DB_PASS);
|
||||
mysql_select_db(DB_NAME);
|
||||
$oDataset = mysql_query('SELECT COUNT(*) FROM REPORT_TABLE') || ($bExists = false);
|
||||
|
||||
|
||||
return $bExists;
|
||||
}
|
||||
|
||||
@@ -713,7 +801,7 @@ class database extends database_base {
|
||||
$sql = ' LIMIT '.(($nCurrentPage-1)*$nRowsPerPage).', '.$nRowsPerPage;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determining the existence of a table
|
||||
*/
|
||||
|
||||
@@ -129,7 +129,7 @@ CLI::taskDescription(<<<EOT
|
||||
|
||||
If no workspace is specified, the command will be run in all workspaces. More
|
||||
than one workspace can be specified.
|
||||
|
||||
|
||||
This command is a shortcut to execute all upgrade commands for workspaces.
|
||||
Upgrading a workspace will make it correspond to the current version of
|
||||
ProcessMaker.
|
||||
@@ -147,7 +147,7 @@ CLI::taskDescription(<<<EOT
|
||||
|
||||
If no workspace is specified, the command will be run in all workspaces. More
|
||||
than one workspace can be specified.
|
||||
|
||||
|
||||
This command will go through each language installed in ProcessMaker and
|
||||
update this workspace translations to match the current version of
|
||||
ProcessMaker.
|
||||
@@ -257,7 +257,7 @@ function database_upgrade($command, $args) {
|
||||
echo "- Indexes (add = " . count($changes['tablesWithNewIndex'])."";
|
||||
echo ", alter = " . count($changes['tablesToAlterIndex']).")\n";
|
||||
} else {
|
||||
echo "> Schema fixed\n";
|
||||
echo "-> Schema fixed\n";
|
||||
}
|
||||
} else {
|
||||
echo "> OK\n";
|
||||
@@ -276,11 +276,11 @@ function delete_app_from_table($con, $tableName, $appUid, $col="APP_UID") {
|
||||
|
||||
function run_drafts_clean($args, $opts) {
|
||||
echo "Cleaning drafts\n";
|
||||
|
||||
|
||||
if (count($args) < 1)
|
||||
throw new Exception ("Please specify a workspace name");
|
||||
$workspace = $args[0];
|
||||
|
||||
|
||||
if (!file_exists(PATH_DB . $workspace . '/db.php')) {
|
||||
throw new Exception('Could not find workspace ' . $workspace);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ function run_workspace_backup($args, $opts) {
|
||||
CLI::logging("\n");
|
||||
$workspace->printMetadata(false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function run_workspace_restore($args, $opts) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,13 +2,13 @@
|
||||
/**
|
||||
* Utility functions to manage a workspace.
|
||||
*
|
||||
* @author Alexandre Rosenfeld
|
||||
* @author Alexandre Rosenfeld
|
||||
*/
|
||||
|
||||
G::LoadSystem('dbMaintenance');
|
||||
G::LoadClass("cli");
|
||||
|
||||
/**
|
||||
/**
|
||||
* class workspaceTools
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
@@ -129,7 +129,7 @@ class workspaceTools {
|
||||
* Reset the database information to that of a newly created workspace.
|
||||
*
|
||||
* This assumes this workspace already has a db.php file, which will be changed
|
||||
* to contain the new information.
|
||||
* to contain the new information.
|
||||
* This function will reset the database hostname to the system database.
|
||||
* If reseting database names, it will also use the the prefixes rp_,
|
||||
* rb_ and wf_, with the workspace name as database names.
|
||||
@@ -445,7 +445,7 @@ class workspaceTools {
|
||||
$oCriteria = new Criteria();
|
||||
$oCriteria->add(ConfigurationPeer::CFG_UID,'casesList');
|
||||
ConfigurationPeer::doDelete($oCriteria);
|
||||
// end of reset
|
||||
// end of reset
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,6 +470,7 @@ class workspaceTools {
|
||||
public function upgradeDatabase($checkOnly = false) {
|
||||
$systemSchema = System::getSystemSchema();
|
||||
$this->upgradeSchema($systemSchema);
|
||||
$this->upgradeData();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -499,7 +500,7 @@ class workspaceTools {
|
||||
if ($changed) {
|
||||
return $changes;
|
||||
} else {
|
||||
CLI::logging("-> Nothing to change\n");
|
||||
CLI::logging("-> Nothing to change in the data base structure\n");
|
||||
return $changed;
|
||||
}
|
||||
}
|
||||
@@ -560,6 +561,51 @@ class workspaceTools {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function upgradeData() {
|
||||
if (file_exists(PATH_CORE . 'data' . PATH_SEP . 'check.data')) {
|
||||
$checkData = @unserialize(file_get_contents(PATH_CORE . 'data' . PATH_SEP . 'check.data'));
|
||||
if (is_array($checkData)) {
|
||||
foreach ($checkData as $checkThis) {
|
||||
$this->updateThisRegistry($checkThis);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateThisRegistry($data) {
|
||||
$dataBase = $this->getDatabase();
|
||||
$sql = '';
|
||||
switch ($data['action']) {
|
||||
case 1:
|
||||
$sql = $dataBase->generateInsertSQL($data['table'], $data['data']);
|
||||
$message = "-> Row added in {$data['table']}\n";
|
||||
break;
|
||||
case 2:
|
||||
$sql = $dataBase->generateUpdateSQL($data['table'], $data['keys'], $data['data']);
|
||||
$message = "-> Row updated in {$data['table']}\n";
|
||||
break;
|
||||
case 3:
|
||||
$sql = $dataBase->generateDeleteSQL($data['table'], $data['keys'], $data['data']);
|
||||
$message = "-> Row deleted in {$data['table']}\n";
|
||||
break;
|
||||
case 4:
|
||||
$sql = $dataBase->generateSelectSQL($data['table'], $data['keys'], $data['data']);
|
||||
$result = $dataBase->executeQuery($sql);
|
||||
if (!$result) {
|
||||
$sql = $dataBase->generateInsertSQL($data['table'], $data['data']);
|
||||
$message = "-> Row updated in {$data['table']}\n";
|
||||
}
|
||||
else {
|
||||
$sql = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ($sql != '') {
|
||||
$dataBase->executeQuery($sql);
|
||||
CLI::logging($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get metadata from this workspace
|
||||
*
|
||||
@@ -607,9 +653,9 @@ class workspaceTools {
|
||||
return $Fields;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Print the system information gathered from getSysInfo
|
||||
*/
|
||||
*/
|
||||
public static function printSysInfo() {
|
||||
$fields = System::getSysInfo();
|
||||
|
||||
@@ -776,7 +822,7 @@ class workspaceTools {
|
||||
CLI::logging("Copying database to backup...\n");
|
||||
$this->addToBackup($backup, $tempDirectory, $tempDirectory);
|
||||
CLI::logging("Copying files to backup...\n");
|
||||
|
||||
|
||||
$this->addToBackup($backup, $this->path, $this->path, "{$this->name}.files");
|
||||
//Remove leftovers.
|
||||
G::rm_dir($tempDirectory);
|
||||
@@ -821,7 +867,7 @@ class workspaceTools {
|
||||
//TODO: Move to class.dbMaintenance.php
|
||||
/**
|
||||
* executes a mysql script
|
||||
*
|
||||
*
|
||||
* This function supports scripts with -- comments in the beginning of a line
|
||||
* and multi-line statements.
|
||||
* It does not support other forms of comments (such as /*... or {{...}}).
|
||||
@@ -879,7 +925,7 @@ class workspaceTools {
|
||||
$metafiles[] = "$tempDirectory/$filename";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CLI::logging("Found " . count($metafiles) . " workspace(s) in backup\n");
|
||||
|
||||
foreach ($metafiles as $metafile) {
|
||||
@@ -995,7 +1041,7 @@ class workspaceTools {
|
||||
throw new Exception('Could not connect to system database: ' . mysql_error());
|
||||
|
||||
$newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
|
||||
|
||||
|
||||
foreach ($metadata->databases as $db) {
|
||||
$dbName = $newDBNames[$db->name];
|
||||
CLI::logging("+> Restoring database {$db->name} to $dbName\n");
|
||||
@@ -1003,7 +1049,7 @@ class workspaceTools {
|
||||
$workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);
|
||||
$workspace->createDBUser($dbName, $db->pass, "%", $dbName);
|
||||
}
|
||||
|
||||
|
||||
$workspace->upgradeCacheView(false);
|
||||
|
||||
mysql_close($link);
|
||||
|
||||
1
workflow/engine/data/check.data
Normal file
1
workflow/engine/data/check.data
Normal file
@@ -0,0 +1 @@
|
||||
a:1:{i:0;a:5:{s:2:"db";s:2:"wf";s:5:"table";s:7:"DASHLET";s:4:"keys";a:1:{i:0;s:7:"DAS_UID";}s:4:"data";a:8:{i:0;a:3:{s:5:"field";s:7:"DAS_UID";s:4:"type";s:4:"text";s:5:"value";s:32:"00000000000000000000000000000001";}i:1;a:3:{s:5:"field";s:9:"DAS_CLASS";s:4:"type";s:4:"text";s:5:"value";s:22:"dashletOpenVSCompleted";}i:2;a:3:{s:5:"field";s:9:"DAS_TITLE";s:4:"type";s:4:"text";s:5:"value";s:29:"Open Cases VS Completed Cases";}i:3;a:3:{s:5:"field";s:15:"DAS_DESCRIPTION";s:4:"type";s:4:"text";s:5:"value";s:29:"Open Cases VS Completed Cases";}i:4;a:3:{s:5:"field";s:11:"DAS_VERSION";s:4:"type";s:4:"text";s:5:"value";s:3:"1.0";}i:5;a:3:{s:5:"field";s:15:"DAS_CREATE_DATE";s:4:"type";s:4:"date";s:5:"value";s:20:" 2011-10-28 00:00:00";}i:6;a:3:{s:5:"field";s:15:"DAS_UPDATE_DATE";s:4:"type";s:4:"date";s:5:"value";s:20:" 2011-10-28 00:00:00";}i:7;a:3:{s:5:"field";s:10:"DAS_STATUS";s:4:"type";s:3:"int";s:5:"value";i:1;}}s:6:"action";i:4;}}
|
||||
Reference in New Issue
Block a user