Various settings for compatibility with MSSQL

This commit is contained in:
Hector Cortez
2011-01-04 20:27:02 +00:00
parent 598099469e
commit 708746a560
2 changed files with 27 additions and 8 deletions

View File

@@ -254,14 +254,17 @@ class DBTable
function insert () {
$strFields = "";
$strValues = "";
if( defined('DB_ADAPTER'))
$DBEngine = DB_ADAPTER;
else
$DBEngine = 'mysql';
foreach( $this->Fields as $field => $val ) {
$strFields .= $field . ",";
$iskey = false;
if ( isset ( $this->table_keys ) && is_array ( $this->table_keys ) )
$iskey = in_array( $field, $this->table_keys ) && strtoupper(substr(trim($val),0,7) ) == "NEXTVAL";
$dbcType = isset ( $this->_dbc->type ) ? $this->_dbc->type : 'mysql';
$dbcType = isset ( $this->_dbc->type ) ? $this->_dbc->type : $DBEngine;
if( ! $iskey )
$val = "'" . G::sqlEscape( $val , $dbcType ) . "'";
$strValues .= " $val ,";
@@ -290,20 +293,26 @@ class DBTable
$stWhere = '';
$remainKeys = array();
if(defined('DB_ADAPTER'))
$DBEngine = DB_ADAPTER;
else
$DBEngine = 'mysql';
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
foreach( $this->Fields as $field => $val )
{
$iskey = false;
$iskey = in_array( $field, $this->table_keys );
if( $iskey == false ) {
$stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : 'mysql' ) . "', ";
$stQry .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "', ";
}
else {
if( $stWhere == "" ) {
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : 'mysql' ) . "'";
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
}
else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : 'mysql' ) . "'";
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
}
$remainKeys[ $field ] = true;
}
@@ -358,6 +367,10 @@ class DBTable
$stWhere = '';
$remainKeys = array();
if(defined('DB_ADAPTER'))
$DBEngine = DB_ADAPTER;
else
$DBEngine = 'mysql';
foreach ( $this->table_keys as $k => $v ) $remainKeys[ $v ] = false;
if ( is_array ( $this->Fields ) ) {
@@ -367,10 +380,10 @@ class DBTable
$iskey = in_array( $field, $this->table_keys );
if( $iskey == true ) {
if( $stWhere == "" ) {
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : 'mysql' ) . "'";
$stWhere .= $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
}
else {
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : 'mysql' ) . "'";
$stWhere .= " AND " . $field . "='" . G::sqlEscape ( $val, isset( $this->_dbc->type) ? $this->_dbc->type : $DBEngine ) . "'";
}
$remainKeys[ $field ] = true;
}
@@ -412,4 +425,4 @@ class DBTable
{
$this->Fields = $this->_dset->read ();
}
}
}

View File

@@ -1539,6 +1539,12 @@ class G
}
}
/**
* Function MySQLSintaxis
* @access public
* @parameter
* @return Boolean
**/
function MySQLSintaxis()
{
$DBEngine = DB_ADAPTER;