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