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

Inherits CDataBase.

Inherited by CDataBaseAccessNoPDO.

Public Member Functions

 __construct ($aConnectionDetails, $sDatabaseID)
 
- 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

 CompileSelectSql ($aQuery=[])
 
 ConcatenateJoins ($aJoinDirections, $aJoinTables, $aJoinOns)
 
 Sanitize ($sData)
 
 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 = "]"
 
- 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 CDataBaseAccess.php.

Constructor & Destructor Documentation

__construct (   $aConnectionDetails,
  $sDatabaseID 
)

__construct - Object constructor method

public

Parameters
array$aConnectionDetails
Returns
void

Definition at line 34 of file CDataBaseAccess.php.

35  {
36  $sDsn = arr_get($aConnectionDetails, 'sDsn', '');
37  $this->m_sDBUser = arr_get($aConnectionDetails, 'sUser', '');
38  $sPassword = arr_get($aConnectionDetails, 'sPassword', '');
39  $this->m_sDataBaseID = arr_get($aConnectionDetails, 'sDatabaseID', '');
40  $this->m_sDBAuthType = arr_get($aConnectionDetails, 'sDBAuthType', '');
41  $this->m_aDataBases = arr_get($aConnectionDetails, 'aDataBases', []);
42  try
43  {
44  $this->m_oDB = new \PDO($sDsn, $this->m_sDBUser, $sPassword);
45  }
46  catch (\PDOException $oPDOException)
47  {
48  $sDsn = str_replace("Driver={Microsoft Access Driver (*.mdb)", "Driver={Microsoft Access Driver (*.mdb" . ACCDB_STRING . ")", $sDsn);
49  $this->m_oDB = new \PDO($sDsn, $this->m_sDBUser, $sPassword);
50  }
51  \SDExtension\Helper\CLogger::get(LOG_CHANNEL_NAME)->addInfo("Connected to Database: $sDatabaseID");
52  }
static get($sChannel="default", $sLogRoot="")
Definition: CLogger.php:90

Member Function Documentation

BoolValue (   $bData)
protected

BoolValue - Converts Boolean to appropriate value depending on driver

protected

Parameters
bool$bDataBoolean value
Returns
int

Definition at line 154 of file CDataBaseAccess.php.

155  {
156  return $bData ? -1 : 0;
157  }
CompileSelectSql (   $aQuery = [])
protected

CompileSelectSql - Compiles SQL expression

protected

Parameters
array$aWhereArray of conditions
Returns
string WHERE statement

Definition at line 61 of file CDataBaseAccess.php.

62  {
63  $sSelectSQL = "SELECT";
64  if (!empty($aQuery["limit"]))
65  {
66  $sSelectSQL .= " TOP $aQuery[limit] ";
67  }
68  if (!empty($aQuery["select"]))
69  {
70  $sSelectSQL .= " $aQuery[select] ";
71  }
72  else
73  {
74  $sSelectSQL .= " * ";
75  }
76  if (!empty($aQuery["from"]))
77  {
78  $sSelectSQL .= "FROM ";
79  if (!empty($aQuery["join"]))
80  {
81  $sSelectSQL .= "($aQuery[from] $aQuery[join])";
82  }
83  else
84  {
85  $sSelectSQL .= "$aQuery[from] ";
86  }
87  }
88  if (!empty($aQuery["where"]))
89  {
90  $sSelectSQL .= "WHERE $aQuery[where] ";
91  }
92  if (!empty($aQuery["group_by"]))
93  {
94  $sSelectSQL .= "GROUP BY $aQuery[group_by] ";
95  }
96  if (!empty($aQuery["order_by"]))
97  {
98  $sSelectSQL .= "ORDER BY $aQuery[order_by] ";
99  }
100  return $sSelectSQL;
101  }
ConcatenateJoins (   $aJoinDirections,
  $aJoinTables,
  $aJoinOns 
)
protected

ConcatenateJoins - Concatenates JOIN expression

protected

Parameters
array$aJoinDirectionsArray of JOIN Directions
array$aJoinTablesArray of JOIN Tables
array$aJoinOnsArray of JOIN ONs
Returns
string JOIN expression

Definition at line 112 of file CDataBaseAccess.php.

113  {
114  $sJoins = "";
115  $nMaxKey = count($aJoinTables) - 1;
116  foreach (array_reverse($aJoinTables) as $nKey => $sJoinTable)
117  {
118  $sJoinTmp = "";
119  if (empty($sJoins))
120  {
121  $sJoinTmp = " $sJoinTable ";
122  }
123  else
124  {
125  $sJoinTmp = " ($sJoinTable $sJoins) ";
126  }
127  $sJoins = arr_get($aJoinDirections, $nMaxKey - $nKey, "INNER JOIN")
128  . $sJoinTmp
129  . "ON (" . $this->CompileJoinOn(arr_get($aJoinOns, $nMaxKey - $nKey, "")) . ")";
130  }
131  return $sJoins;
132  }
CompileJoinOn($aJoinOn=[])
Definition: CDataBase.php:778
Sanitize (   $sData)
protected

Sanitize - Sanitizes string

protected

Parameters
string$sDataData to sanitize
Returns
string Sanitized string

Definition at line 141 of file CDataBaseAccess.php.

142  {
143  $sData = iconv("UTF-8", "WINDOWS-1256", $sData);
144  return str_replace("'", "''", $sData);
145  }

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