Tutorial Extension  1.0.0
SellerDeck Extensions - Tutorial Extension
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CDataBaseSqlServer Class Reference

Inherits CDataBase.

Public Member Functions

 QuoteTable ($sTableName)
 
- Public Member Functions inherited from CDataBase
 __construct ($aConnectionDetails, $sDatabaseID)
 
 GetDatabaseID ()
 
 GetDataBases ()
 
 GetDBUser ()
 
 GetDBAuthType ()
 
 Expression ($sExpression)
 
 QuoteValue ($vData)
 
 QuoteTable ($vTableName)
 
 QuoteColumn ($vData)
 
 QuoteCompundColumn ($vUnquotedElement)
 
 GetDB ()
 
 GetLastQuery ()
 
 SQL ($sQuery, $nReturnType=\PDO::FETCH_ASSOC)
 
 Insert ($sTable, $aValues, $bAutoID=true, $sIDColumn=null)
 
 Update ($sTable, $aValues, $aWhere=[[1, '', '']])
 
 Select ($sTable, $vColumns="*", $aWhere=[], $aOthers=[], $nReturnType=\PDO::FETCH_ASSOC)
 
 CompileWhere ($aWhere=[], $aBoolOp=BOOP_OP_AND)
 
 CompileJoinOn ($aJoinOn=[])
 

Protected Member Functions

 BasicInsert ($sTable, $aValues)
 
 Sanitize ($sData)
 
 CompileSelectSql ($aQuery=[])
 
 BoolValue ($bData)
 
- Protected Member Functions inherited from CDataBase
 Quote ($sData, $sQuoteBegin, $sQuoteEnd)
 
 Sanitize ($sData)
 
 QuoteArray ($aUnquotedArray, $bValue=true)
 
 QuoteUpdateArray ($aUnquotedArray)
 
 QuoteValueArray ($aUnquotedArray)
 
 QuoteColumnArray ($aUnquotedArray)
 
 QuoteValueList ($aUnquotedArray, $sSeparator=", ")
 
 QuoteColumnList ($aUnquotedArray, $sSeparator=", ")
 
 BasicInsert ($sTable, $aValues)
 
 CompileSelectSql ($aQuery=[])
 
 CompileWhereElement ($aValue=[])
 
 IsElementFormat ($aValue)
 
 CompileLimit ($vLimit)
 
 CompileJoin ($aJoins)
 
 ConcatenateJoins ($aJoinDirections, $aJoinTables, $aJoinOns)
 
 CompileGroupBy ($aGroupByList)
 
 CompileOrderBy ($aOrderByList)
 
 BoolValue ($bData)
 

Protected Attributes

 $m_sColumnQuoteBegin = "["
 
 $m_sColumnQuoteEnd = "]"
 
 $m_aCatalogTables
 
- Protected Attributes inherited from CDataBase
 $m_oDB = null
 
 $m_sDataBaseID = DB_CATALOG
 
 $m_sDBAuthType = "DB"
 
 $m_sDBUser = "dbo"
 
 $m_aDataBases = []
 
 $m_sColumnQuoteBegin = '`'
 
 $m_sColumnQuoteEnd = '`'
 
 $m_sValueQuoteBegin = "'"
 
 $m_sValueQuoteEnd = "'"
 
 $m_sNullValue = "NULL"
 
 $m_sLastQuery = ""
 

Detailed Description

Definition at line 14 of file CDataBaseSqlServer.php.

Member Function Documentation

BasicInsert (   $sTable,
  $aValues 
)
protected

BasicInsert - Generates and runs Basic INSERT expression

protected

Parameters
string$sTableTable name
array$aValuesArray of (DB Column => Value) pairs
Returns
mixed Last inserted ID

Definition at line 162 of file CDataBaseSqlServer.php.

163  {
164  $sTableQuoted = $this->QuoteTable($sTable);
165  $sColumnList = $this->QuoteColumnList(array_keys($aValues));
166  $sValueList = $this->QuoteValueList(array_values($aValues));
167  $sQuery = "INSERT INTO $sTableQuoted (" . $sColumnList . ") VALUES (" . $sValueList . ");";
168  $nResult = $this->m_oDB->exec($sQuery);
169  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addDebug(__FUNCTION__ . " : $sQuery");
170  return $this->m_oDB->lastInsertId();
171  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90
QuoteValueList($aUnquotedArray, $sSeparator=", ")
Definition: CDataBase.php:375
QuoteColumnList($aUnquotedArray, $sSeparator=", ")
Definition: CDataBase.php:389
BoolValue (   $bData)
protected

BoolValue - Converts Boolean to appropriate value depending on driver

protected

Parameters
bool$bDataBoolean value
Returns
int

Definition at line 241 of file CDataBaseSqlServer.php.

242  {
243  return $bData ? 1 : 0;
244  }
CompileSelectSql (   $aQuery = [])
protected

CompileSelectSql - Compiles SQL expression

protected

Parameters
array$aWhereArray of conditions
Returns
string WHERE statement

Definition at line 192 of file CDataBaseSqlServer.php.

193  {
194  $sSelectSQL = "SELECT";
195  if (!empty($aQuery["limit"]))
196  {
197  $sSelectSQL .= " TOP $aQuery[limit] ";
198  }
199  if (!empty($aQuery["select"]))
200  {
201  $sSelectSQL .= " $aQuery[select] ";
202  }
203  else
204  {
205  $sSelectSQL .= " * ";
206  }
207  if (!empty($aQuery["from"]))
208  {
209  $sSelectSQL .= "FROM ";
210  if (!empty($aQuery["join"]))
211  {
212  $sSelectSQL .= "($aQuery[from] $aQuery[join])";
213  }
214  else
215  {
216  $sSelectSQL .= "$aQuery[from] ";
217  }
218  }
219  if (!empty($aQuery["where"]))
220  {
221  $sSelectSQL .= "WHERE $aQuery[where] ";
222  }
223  if (!empty($aQuery["group_by"]))
224  {
225  $sSelectSQL .= "GROUP BY $aQuery[group_by] ";
226  }
227  if (!empty($aQuery["order_by"]))
228  {
229  $sSelectSQL .= "ORDER BY $aQuery[order_by] ";
230  }
231  return $sSelectSQL;
232  }
QuoteTable (   $sTableName)

QuoteTable - Quotes Table name

public

Parameters
string$sTableNameTable name
Returns
string Quoted Table name

Definition at line 146 of file CDataBaseSqlServer.php.

147  {
148  $sDataBaseID = arr_get($this->GetDataBases(), $this->GetDatabaseID(), null);
149  return $this->QuoteColumn($sDataBaseID) . "." .
150  $this->QuoteColumn(DB_COMMON_DBO) . "." .
151  $this->QuoteColumn($sTableName);
152  }
Sanitize (   $sData)
protected

Sanitize - Sanitizes string

protected

Parameters
string$sDataData to sanitize
Returns
string Sanitized string

Definition at line 180 of file CDataBaseSqlServer.php.

181  {
182  return str_replace("'", "''", $sData);
183  }

The documentation for this class was generated from the following file: