Various settings in the Suggest

This commit is contained in:
Hector Cortez
2011-03-10 16:24:21 +00:00
parent c8529214e6
commit 9fbcc602c8
5 changed files with 46 additions and 10 deletions

View File

@@ -709,4 +709,16 @@ class database extends database_base {
return $sql;
}
/**
* Determining the existence of a table
*/
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);
mssql_select_db(DB_NAME);
$oDataset = mssql_query($sql) || ($bExists = false);
return $bExists;
}
}

View File

@@ -714,4 +714,17 @@ class database extends database_base {
return $sql;
}
/**
* Determining the existence of a table
*/
function tableExists ($table, $db) {
$tables = mysql_list_tables ($db);
while (list ($temp) = @mysql_fetch_array ($tables)) {
if ($temp == $table) {
return TRUE;
}
}
return FALSE;
}
}

View File

@@ -258,7 +258,6 @@ class XmlForm_Field {
return 1;
if ($this->sql === '')
return 1;
if (! $this->sqlConnection)
$this->sqlConnection = 'workflow';
@@ -995,6 +994,8 @@ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek
{
//echo $this->sqlConnection;
if (! $this->sqlConnection)
$this->sqlConnection = 'workflow';
//NOTE: string functions must be in G class
if ($this->strTo === 'UPPER')

View File

@@ -155,6 +155,15 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
if( $type == 'suggest' && isset($Fields['PME_SQLCONNECTION']) && $Fields['PME_SQLCONNECTION']!='') {
//define the dbArray with the table fields
//g::pr($Fields);
$tableExists = true;
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
if(G::LoadSystemExist($sDataBase)){
G::LoadSystem($sDataBase);
$oDataBase = new database();
$tableExists = $oDataBase->tableExists('USERS', $Fields['PME_SQLCONNECTION']);
}
if($tableExists) {
$con = Propel::getConnection($Fields['PME_SQLCONNECTION']);
$rs = $con->executeQuery("SHOW COLUMNS FROM USERS");
$result = Array();
@@ -162,8 +171,9 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
while ($rs->next()) {
$result[$i++] = $rs->getRow();
}
//g::pr($result);
}
}
//g::pr($result);
if( isset($Fields['PME_HINT']) ) {

View File

@@ -59,7 +59,7 @@ if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Respons
$_POST['form']['PME_SAVELABEL'] = 0;
}
if (isset($_POST['form']['PME_SAVELABEL'])){
if (isset($_POST['form']['PME_SAVELABEL']) && isset($_POST['form']['PME_CODE'])){
$pmeCode = $_POST['form']['PME_CODE'];
$pmeCode = str_replace("'", "''", $pmeCode);
$pmeCode = str_replace('"', '""', $pmeCode);