Overview

Packages

  • Actions
  • Codegen
  • Controls
    • Base
  • DatabaseAdapters
  • Events
  • None
  • Sessions
  • Tests

Classes

  • AbstractControl_CodeGenerator
  • AjaxTimingForm
  • BasicForm
  • BasicOrmTests
  • BBCodeParser
  • CacheTests
  • CalculatorForm
  • CalculatorWidget
  • ComplexColumn
  • DataRepeaterExample
  • Event
  • ExampleCheckColumn1
  • ExampleCheckColumn2
  • ExampleForm
  • Examples
  • ExampleService
  • ExamplesForm
  • ExampleSingleForm
  • ExpandAsArrayTests
  • HtmlJqDoc
  • InjectForm
  • JavaScriptHelper
  • JqAttributes
  • JqControlGen
  • JqDoc
  • JqIcon
  • Method
  • ModelConnectorTests
  • MyControl
  • MyQSlider_ChangeEvent
  • NavPanel
  • NestedTabForm
  • Option
  • Order
  • PaginatorForm
  • ParamsForm
  • PersistentExampleForm
  • PersonEditPanel
  • PluginEditForm
  • PluginManagerForm
  • Project
  • ProjectEditPanel
  • ProjectListForm
  • ProjectPickerListBox
  • ProjectViewPanel
  • QAbstractCacheProvider
  • QAbstractHtmlTableColumn
  • QAbstractHtmlTableDataColumn
  • QAccordion
  • QAccordion_ActivateEvent
  • QAccordion_BeforeActivateEvent
  • QAccordion_CreateEvent
  • QAccordionBase
  • QAccordionGen
  • QAction
  • QActionControl
  • QAjaxAction
  • QAjaxControlAction
  • QAjaxResponse
  • QAlertAction
  • QApplication
  • QApplicationBase
  • QArchive
  • QAutocomplete
  • QAutocomplete_ChangeEvent
  • QAutocomplete_CloseEvent
  • QAutocomplete_CodeGenerator
  • QAutocomplete_CreateEvent
  • QAutocomplete_FocusEvent
  • QAutocomplete_OpenEvent
  • QAutocomplete_ResponseEvent
  • QAutocomplete_SearchEvent
  • QAutocomplete_SelectEvent
  • QAutocomplete_SourceEvent
  • QAutocompleteBase
  • QAutocompleteBase_CodeGenerator
  • QAutocompleteGen
  • QAutocompleteListItem
  • QBackspaceKeyEvent
  • QBaseClass
  • QBlockControl
  • QBlurControlAction
  • QBlurEvent
  • QBorderCollapse
  • QBorderStyle
  • QBrowserType
  • QButton
  • QButtonBase
  • QCache
  • QCacheDeleteAction
  • QCacheDeleteAllAction
  • QCacheProviderAPC
  • QCacheProviderLocalMemory
  • QCacheProviderLocalMemoryTest
  • QCacheProviderMemcache
  • QCacheProviderNoCache
  • QCacheProviderProxy
  • QCacheSetAction
  • QCalendar
  • QCalendarType
  • QCallType
  • QCausesValidation
  • QCellClickEvent
  • QChangeEvent
  • QCheckBox
  • QCheckBox_CodeGenerator
  • QCheckBoxBase_CodeGenerator
  • QCheckBoxLegacyColumn
  • QCheckBoxList
  • QCheckBoxList_CodeGenerator
  • QCheckBoxListBase_CodeGenerator
  • QClickEvent
  • QCodeGen
  • QCodeGenBase
  • QConfirmAction
  • QContextMenuEvent
  • QControl
  • QControl_CodeGenerator
  • QControlBase
  • QControlBase_CodeGenerator
  • QControlBaseTests
  • QControlCategoryType
  • QControlGrouping
  • QControlLabel
  • QControlProxy
  • QConvertNotation
  • QConvertNotationBase
  • QCrossScripting
  • QCryptography
  • QCss
  • QCssAction
  • QCssClassAction
  • QCssTests
  • QCsvTextBox
  • QCursor
  • QDatabaseBase
  • QDatabaseCodeGen
  • QDatabaseFieldBase
  • QDatabaseFieldType
  • QDatabaseForeignKey
  • QDatabaseIndex
  • QDatabaseResultBase
  • QDatabaseRowBase
  • QDatabaseTests
  • QDataGrid
  • QDataGrid_CheckBoxColumn
  • QDataGrid_CodeGenerator
  • QDataGrid_SortEvent
  • QDataGridBase
  • QDataGridBase_CodeGenerator
  • QDataGridLegacy
  • QDataGridLegacyBase
  • QDataGridLegacyColumn
  • QDataGridLegacyRow
  • QDataGridLegacyRowStyle
  • QDataRepeater
  • QDatepicker
  • QDatepicker_BeforeShowDayEvent
  • QDatepicker_BeforeShowEvent
  • QDatepicker_CalculateWeekEvent
  • QDatepicker_ChangeMonthYearEvent
  • QDatepicker_CloseEvent
  • QDatepicker_SelectEvent
  • QDatepicker_SelectEvent2
  • QDatepickerBase
  • QDatepickerBox
  • QDatepickerBox_BeforeShowDayEvent
  • QDatepickerBox_BeforeShowEvent
  • QDatepickerBox_CalculateWeekEvent
  • QDatepickerBox_ChangeMonthYearEvent
  • QDatepickerBox_CloseEvent
  • QDatepickerBox_CodeGenerator
  • QDatepickerBox_SelectEvent
  • QDatepickerBoxBase
  • QDatepickerBoxBase_CodeGenerator
  • QDatepickerBoxGen
  • QDatepickerGen
  • QDateTime
  • QDateTimePicker
  • QDateTimePicker_CodeGenerator
  • QDateTimePickerBase_CodeGenerator
  • QDateTimePickerFormat
  • QDateTimePickerType
  • QDateTimeSpan
  • QDateTimeTests
  • QDateTimeTextBox
  • QDbBackedFormStateHandler
  • QDbBackedSessionHandler
  • QDialog
  • QDialog_BeforeCloseEvent
  • QDialog_ButtonEvent
  • QDialog_CloseEvent
  • QDialog_CreateEvent
  • QDialog_DragEvent
  • QDialog_DragStartEvent
  • QDialog_DragStopEvent
  • QDialog_FocusEvent
  • QDialog_OpenEvent
  • QDialog_ResizeEvent
  • QDialog_ResizeStartEvent
  • QDialog_ResizeStopEvent
  • QDialogBase
  • QDialogBox
  • QDialogGen
  • QDisplayStyle
  • QDoubleClickEvent
  • QDownArrowKeyEvent
  • QDragDropEvent
  • QDraggable
  • QDraggable_CreateEvent
  • QDraggable_DragEvent
  • QDraggable_StartEvent
  • QDraggable_StopEvent
  • QDraggableBase
  • QDraggableGen
  • QDroppable
  • QDroppable_ActivateEvent
  • QDroppable_CreateEvent
  • QDroppable_DeactivateEvent
  • QDroppable_DropEvent
  • QDroppable_OutEvent
  • QDroppable_OverEvent
  • QDroppableBase
  • QDroppableGen
  • QDropZoneGrouping
  • QEmailAttachment
  • QEmailMessage
  • QEmailServer
  • QEmailStringAttachment
  • QEmailTextBox
  • QEnterKeyEvent
  • QErrorAttribute
  • QEscapeKeyEvent
  • QEvent
  • QFieldset
  • QFile
  • QFileAsset
  • QFileAssetBase
  • QFileAssetDialog
  • QFileAssetType
  • QFileControl
  • QFileFormStateHandler
  • QFilterType
  • QFloatTextBox
  • QFloatTextBox_CodeGenerator
  • QFloatTextBoxBase_CodeGenerator
  • QFocusControlAction
  • QFocusEvent
  • QFocusInEvent
  • QFocusOutEvent
  • QFolder
  • QFontFamily
  • QForm
  • QFormBase
  • QFormGen
  • QFormStateHandler
  • QGridLines
  • QHideCalendarAction
  • QHideDialog
  • QHideDialogBox
  • QHListControl
  • QHListItem
  • QHorizontalAlign
  • QHtml
  • QHtmlAttributeManager
  • QHtmlAttributeManagerBase
  • QHtmlReporter
  • QHtmlTable
  • QHtmlTable_CodeGenerator
  • QHtmlTableBase
  • QHtmlTableCallableColumn
  • QHtmlTableCheckBoxColumn
  • QHtmlTableCheckBoxColumn_ClickEvent
  • QHtmlTableIndexedColumn
  • QHtmlTableLinkColumn
  • QHtmlTableNodeColumn
  • QHtmlTablePropertyColumn
  • QI18n
  • QI18nTests
  • QImageBase
  • QImageBrowser
  • QImageBrowserBase
  • QImageBrowserNav
  • QImageBrowserThumbnails
  • QImageButton
  • QImageControl
  • QImageControlBase
  • QImageFileAsset
  • QImageLabel
  • QImageLabelBase
  • QImageRollover
  • QImageType
  • QIndex
  • QInformixPdoDatabase
  • QInformixPdoDatabaseField
  • QInformixPdoDatabaseResult
  • QInformixPdoDatabaseRow
  • QInputEvent
  • QInstallationValidationResult
  • QInstallationValidator
  • QIntegerTextBox
  • QIntegerTextBox_CodeGenerator
  • QIntegerTextBoxBase_CodeGenerator
  • QJavaScriptAction
  • QJQAction
  • QJQBounceAction
  • QJqButton
  • QJqButton_CreateEvent
  • QJqButtonBase
  • QJqButtonGen
  • QJqCheckBox
  • QJqCheckBox_CreateEvent
  • QJqCheckBoxBase
  • QJqCheckBoxGen
  • QJQHideAction
  • QJQHideEffectAction
  • QJQHighlightAction
  • QJQPulsateAction
  • QJqRadioButton
  • QJqRadioButton_CreateEvent
  • QJqRadioButtonBase
  • QJqRadioButtonGen
  • QJQShakeAction
  • QJQShowAction
  • QJQShowEffectAction
  • QJQSizeAction
  • QJQToggleAction
  • QJQToggleEffectAction
  • QJQTransferAction
  • QJqUiEvent
  • QJqUiPropertyEvent
  • QJsClosure
  • QJsFunction
  • QJsNoQuoteKey
  • QJsParameterList
  • QJsPriority
  • QJsTimer
  • QJsTimerBase
  • QJsVarName
  • QKeyDownEvent
  • QKeyPressEvent
  • QKeyUpEvent
  • QLabel
  • QLabel_CodeGenerator
  • QLabelBase_CodeGenerator
  • QLexer
  • QLinkButton
  • QListBox
  • QListBox_CodeGenerator
  • QListBoxBase
  • QListBoxBase_CodeGenerator
  • QListControl
  • QListControl_CodeGenerator
  • QListControlBase_CodeGenerator
  • QListItem
  • QListItemBase
  • QListItemStyle
  • QManyToManyReference
  • QMenu
  • QMenu_BlurEvent
  • QMenu_CreateEvent
  • QMenu_FocusEvent
  • QMenu_SelectEvent
  • QMenuBase
  • QMenuGen
  • QMimeType
  • QModelConnectorArgumentType
  • QModelConnectorCreateType
  • QModelConnectorEditDlg
  • QModelConnectorOptions
  • QModelConnectorParam
  • QMouseDownEvent
  • QMouseEnterEvent
  • QMouseLeaveEvent
  • QMouseMoveEvent
  • QMouseOutEvent
  • QMouseOverEvent
  • QMouseUpEvent
  • QMultiLevelCacheProvider
  • QMySqlDatabase
  • QMySqlDatabaseField
  • QMySqlDatabaseResult
  • QMySqli5ClusterDatabase
  • QMySqli5Database
  • QMySqli5DatabaseField
  • QMySqli5DatabaseResult
  • QMySqliDatabase
  • QMySqliDatabaseField
  • QMySqliDatabaseResult
  • QMySqliDatabaseRow
  • QNoScriptAjaxAction
  • QNumericTextBox
  • QOnEvent
  • QOracleDatabase
  • QOracleDatabaseField
  • QOracleDatabaseResult
  • QOracleDatabaseRow
  • QOrderedListType
  • QOverflow
  • QPaginatedControl
  • QPaginator
  • QPaginatorBase
  • QPanel
  • QPartialQueryBuilder
  • QPdoDatabase
  • QPdoDatabaseResult
  • QPgConditionILike
  • QPgConditionJsonContains
  • QPgQ
  • QPosition
  • QPostgreSqlDatabase
  • QPostgreSqlDatabaseField
  • QPostgreSqlDatabaseResult
  • QPostgreSqlDatabaseRow
  • QPostgreSqlPdoDatabase
  • QPostgreSqlPdoDatabaseField
  • QPostgreSqlPdoDatabaseResult
  • QPostgreSqlPdoDatabaseRow
  • QProgressbar
  • QProgressbar_ChangeEvent
  • QProgressbar_CompleteEvent
  • QProgressbar_CreateEvent
  • QProgressbarBase
  • QProgressbarGen
  • QQ
  • QQAggregationClause
  • QQAliasTests
  • QQAssociationNode
  • QQAverage
  • QQClause
  • QQColumnNode
  • QQCondition
  • QQConditionAll
  • QQConditionAnd
  • QQConditionBetween
  • QQConditionComparison
  • QQConditionEqual
  • QQConditionExists
  • QQConditionGreaterOrEqual
  • QQConditionGreaterThan
  • QQConditionIn
  • QQConditionIsNotNull
  • QQConditionIsNull
  • QQConditionLessOrEqual
  • QQConditionLessThan
  • QQConditionLike
  • QQConditionLogical
  • QQConditionNone
  • QQConditionNot
  • QQConditionNotBetween
  • QQConditionNotEqual
  • QQConditionNotExists
  • QQConditionNotIn
  • QQConditionNotLike
  • QQConditionOr
  • QQCount
  • QQDistinct
  • QQExpand
  • QQExpandAsArray
  • QQExpandVirtualNode
  • QQFuncTests
  • QQFunctionNode
  • QQGroupBy
  • QQHavingClause
  • QQLimitInfo
  • QQMathNode
  • QQMathOpTests
  • QQMaximum
  • QQMinimum
  • QQNamedValue
  • QQNode
  • QQNoParentNode
  • QQOrderBy
  • QQReverseReferenceNode
  • QQSelect
  • QQSubQueryCountNode
  • QQSubQueryNode
  • QQSubQuerySqlNode
  • QQSum
  • QQTableNode
  • QQuery
  • QQueryBuilder
  • QQueryExpansion
  • QQVirtualNode
  • QRadioButton
  • QRadioButtonList
  • QRadioButtonList_CodeGenerator
  • QRadioButtonListBase_CodeGenerator
  • QRedirectAction
  • QReference
  • QRegex
  • QRegisterClickPositionAction
  • QRepeatDirection
  • QRequestMode
  • QResetTimerAction
  • QResizable
  • QResizable_CreateEvent
  • QResizable_ResizeEvent
  • QResizable_StartEvent
  • QResizable_StopEvent
  • QResizableBase
  • QResizableGen
  • QResizeHandleDirection
  • QRestServiceCodeGen
  • QReverseReference
  • QRssCategory
  • QRssFeed
  • QRssImage
  • QRssItem
  • QSampleControl
  • QSampleTranslation
  • QSelectable
  • QSelectable_CreateEvent
  • QSelectable_SelectedEvent
  • QSelectable_SelectingEvent
  • QSelectable_StartEvent
  • QSelectable_StopEvent
  • QSelectable_UnselectedEvent
  • QSelectable_UnselectingEvent
  • QSelectableBase
  • QSelectableGen
  • QSelectControlAction
  • QSelectEvent
  • QSelectionMode
  • QSelectMenu
  • QSelectMenu_ChangeEvent
  • QSelectMenu_CloseEvent
  • QSelectMenu_CreateEvent
  • QSelectMenu_FocusEvent
  • QSelectMenu_OpenEvent
  • QSelectMenu_SelectEvent
  • QSelectMenuBase
  • QSelectMenuGen
  • QServerAction
  • QServerControlAction
  • QSessionFormStateHandler
  • QSetValueAction
  • QShowCalendarAction
  • QShowDialog
  • QShowDialogBox
  • QSlider
  • QSlider_ChangeEvent
  • QSlider_CodeGenerator
  • QSlider_CreateEvent
  • QSlider_SlideEvent
  • QSlider_StartEvent
  • QSlider_StopEvent
  • QSliderBase
  • QSliderBase_CodeGenerator
  • QSliderGen
  • QSoapMethod
  • QSoapParameter
  • QSoapService
  • QSortable
  • QSortable_ActivateEvent
  • QSortable_BeforeStopEvent
  • QSortable_ChangeEvent
  • QSortable_CreateEvent
  • QSortable_DeactivateEvent
  • QSortable_OutEvent
  • QSortable_OverEvent
  • QSortable_ReceiveEvent
  • QSortable_RemoveEvent
  • QSortable_SortEvent
  • QSortable_StartEvent
  • QSortable_StopEvent
  • QSortable_UpdateEvent
  • QSortableBase
  • QSortableGen
  • QSpinner
  • QSpinner_ChangeEvent
  • QSpinner_CreateEvent
  • QSpinner_SpinEvent
  • QSpinner_StartEvent
  • QSpinner_StopEvent
  • QSpinnerBase
  • QSpinnerGen
  • QSqlColumn
  • QSqLite3PdoDatabase
  • QSqLite3PdoDatabaseField
  • QSqLite3PdoDatabaseResult
  • QSqLite3PdoDatabaseRow
  • QSqlServer2005Database
  • QSqlServer2005DatabaseField
  • QSqlServer2005DatabaseResult
  • QSqlServer2005DatabaseRow
  • QSqlServerDatabase
  • QSqlServerDatabaseField
  • QSqlServerDatabaseResult
  • QSqlServerDatabaseRow
  • QSqlTable
  • QStack
  • QStopPropagationAction
  • QString
  • QStringTest
  • QTabKeyEvent
  • QTabs
  • QTabs_ActivateEvent
  • QTabs_BeforeActivateEvent
  • QTabs_BeforeLoadEvent
  • QTabs_CreateEvent
  • QTabs_LoadEvent
  • QTabsBase
  • QTabsGen
  • QTag
  • QTagStyler
  • QTerminateAction
  • QTestControl
  • QTestForm
  • QTextAlign
  • QTextBox
  • QTextBox_CodeGenerator
  • QTextBoxBase
  • QTextBoxBase_CodeGenerator
  • QTextMode
  • QTimer
  • QTimerExpiredEvent
  • QTimerTests
  • QToggleCssClassAction
  • QToggleDisplayAction
  • QToggleEnableAction
  • QTranslationPoParser
  • QTreeNav
  • QTreeNavItem
  • QType
  • QTypeTable
  • QTypeTests
  • QUnitTestCaseBase
  • QUnorderedListStyle
  • QUpArrowKeyEvent
  • QUrlTextBox
  • QVerticalAlign
  • QVirtualAttributeColumn
  • QWaitIcon
  • QWatcher
  • QWatcherBase
  • QWatcherCache
  • QWatcherDB
  • QWatcherNone
  • QWriteBox
  • RecordsSummary
  • RefreshForm
  • SampleComposite
  • SampleForm
  • SelectableLabel
  • SelectForm
  • SpeedForm
  • TestImageBrowser
  • UrlForm

Interfaces

  • ICacheAction
  • QDataList_CodeGenerator_Interface
  • QTranslationBase

Traits

  • QDataBinder
  • QListItemManager
  • QModelTrait

Exceptions

  • QCallerException
  • QCrossScriptingException
  • QCryptographyException
  • QDatabaseExceptionBase
  • QDataBindException
  • QDateTimeNullException
  • QEmailException
  • QIndexOutOfRangeException
  • QInformixPdoDatabaseException
  • QInvalidCastException
  • QInvalidFormStateException
  • QMySqliDatabaseException
  • QOptimisticLockingException
  • QOracleDatabaseException
  • QPdoDatabaseException
  • QPoParserException
  • QPostgreSqlDatabaseException
  • QPostgreSqlPdoDatabaseException
  • QRemoteAdminDeniedException
  • QSqLite3PdoDatabaseException
  • QSqlServer2005DatabaseException
  • QSqlServerDatabaseException
  • QUndefinedMethodException
  • QUndefinedPrimaryKeyException
  • QUndefinedPropertyException

Functions

  • __database_check_error
  • __QForm_EvaluateTemplate_ObHandler
  • _b
  • _indent
  • _nl
  • _p
  • _r
  • _t
  • _tp
  • _tr
  • array_trim
  • beginsWith
  • CamelCaseFromDash
  • CastToInt
  • DataGridEvalHandleError
  • DisplayMonospacedText
  • endsWith
  • GO_BACK
  • jq_anytime_gen
  • jq_control_gen
  • jq_inc_gen
  • jq_indent
  • PrintExplainStatement
  • PrintInstructions
  • QcubedHandleCodeGenParseError
  • QcubedHandleError
  • QcubedHandleException
  • QCubedShutdown
  • QDateTimeErrorHandler
  • trimOffEnd
  • trimOffFront
  • Overview
  • Package
  • Class
  1: <?php
  2: 
  3: if (!defined('MYSQLI_ON_UPDATE_NOW_FLAG')) {
  4:     define ('MYSQLI_ON_UPDATE_NOW_FLAG', 8192);
  5: }
  6:     /**
  7:      *
  8:      * @package DatabaseAdapters
  9:      */
 10:     class QMySqliDatabase extends QDatabaseBase {
 11:         const Adapter = 'MySql Improved Database Adapter for MySQL 4';
 12: 
 13:         protected $objMySqli;
 14: 
 15:         protected $strEscapeIdentifierBegin = '`';
 16:         protected $strEscapeIdentifierEnd = '`';
 17: 
 18:         public function SqlLimitVariablePrefix($strLimitInfo) {
 19:             // MySQL uses Limit by Suffixes (via a LIMIT clause)
 20: 
 21:             // If requested, use SQL_CALC_FOUND_ROWS directive to utilize GetFoundRows() method
 22:             if (array_key_exists('usefoundrows', $this->objConfigArray) && $this->objConfigArray['usefoundrows'])
 23:                 return 'SQL_CALC_FOUND_ROWS';
 24: 
 25:             return null;
 26:         }
 27: 
 28:         public function SqlLimitVariableSuffix($strLimitInfo) {
 29:             // Setup limit suffix (if applicable) via a LIMIT clause 
 30:             if (strlen($strLimitInfo)) {
 31:                 if (strpos($strLimitInfo, ';') !== false)
 32:                     throw new Exception('Invalid Semicolon in LIMIT Info');
 33:                 if (strpos($strLimitInfo, '`') !== false)
 34:                     throw new Exception('Invalid Backtick in LIMIT Info');
 35:                 return "LIMIT $strLimitInfo";
 36:             }
 37: 
 38:             return null;
 39:         }
 40: 
 41:         public function SqlSortByVariable($strSortByInfo) {
 42:             // Setup sorting information (if applicable) via a ORDER BY clause
 43:             if (strlen($strSortByInfo)) {
 44:                 if (strpos($strSortByInfo, ';') !== false)
 45:                     throw new Exception('Invalid Semicolon in ORDER BY Info');
 46:                 if (strpos($strSortByInfo, '`') !== false)
 47:                     throw new Exception('Invalid Backtick in ORDER BY Info');
 48: 
 49:                 return "ORDER BY $strSortByInfo";
 50:             }
 51:             
 52:             return null;
 53:         }
 54: 
 55:         public function InsertOrUpdate($strTable, $mixColumnsAndValuesArray, $strPKNames = null) {
 56:             $strEscapedArray = $this->EscapeIdentifiersAndValues($mixColumnsAndValuesArray);
 57:             $strUpdateStatement = '';
 58:             foreach ($strEscapedArray as $strColumn => $strValue) {
 59:                 if ($strUpdateStatement) $strUpdateStatement .= ', ';
 60:                 $strUpdateStatement .= $strColumn . ' = ' . $strValue;
 61:             }
 62:             $strSql = sprintf('INSERT INTO %s%s%s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s',
 63:                 $this->EscapeIdentifierBegin, $strTable, $this->EscapeIdentifierEnd,
 64:                 implode(', ', array_keys($strEscapedArray)),
 65:                 implode(', ', array_values($strEscapedArray)),
 66:                 $strUpdateStatement
 67:             );
 68:             $this->ExecuteNonQuery($strSql);
 69:         }
 70: 
 71:         public function Connect() {
 72:             // Connect to the Database Server
 73:             $this->objMySqli = new MySqli($this->Server, $this->Username, $this->Password, $this->Database, $this->Port);
 74: 
 75:             if (!$this->objMySqli)
 76:                 throw new QMySqliDatabaseException("Unable to connect to Database", -1, null);
 77:             
 78:             if ($this->objMySqli->error)
 79:                 throw new QMySqliDatabaseException($this->objMySqli->error, $this->objMySqli->errno, null);
 80: 
 81:             // Update "Connected" Flag
 82:             $this->blnConnectedFlag = true;
 83: 
 84:             // Set to AutoCommit
 85:             $this->NonQuery('SET AUTOCOMMIT=1;');
 86: 
 87:             // Set NAMES (if applicable)
 88:             if (array_key_exists('encoding', $this->objConfigArray))
 89:                 $this->NonQuery('SET NAMES ' . $this->objConfigArray['encoding'] . ';');
 90:         }
 91: 
 92:         public function __get($strName) {
 93:             switch ($strName) {
 94:                 case 'AffectedRows':
 95:                     return $this->objMySqli->affected_rows;
 96:                 default:
 97:                     try {
 98:                         return parent::__get($strName);
 99:                     } catch (QCallerException $objExc) {
100:                         $objExc->IncrementOffset();
101:                         throw $objExc;
102:                     }
103:             }
104:         }
105: 
106:         protected function ExecuteQuery($strQuery) {
107:             // Perform the Query
108:             $objResult = $this->objMySqli->query($strQuery);
109:             if ($this->objMySqli->error)
110:                 throw new QMySqliDatabaseException($this->objMySqli->error, $this->objMySqli->errno, $strQuery);
111: 
112:             // Return the Result
113:             $objMySqliDatabaseResult = new QMySqliDatabaseResult($objResult, $this);
114:             return $objMySqliDatabaseResult;
115:         }
116: 
117:         protected function ExecuteNonQuery($strNonQuery) {
118:             // Perform the Query
119:             $this->objMySqli->query($strNonQuery);
120:             if ($this->objMySqli->error)
121:                 throw new QMySqliDatabaseException($this->objMySqli->error, $this->objMySqli->errno, $strNonQuery);
122:         }
123:         
124:         public function GetTables() {
125:             // Use the MySQL "SHOW TABLES" functionality to get a list of all the tables in this database
126:             $objResult = $this->Query("SHOW TABLES");
127:             $strToReturn = array();
128:             while ($strRowArray = $objResult->FetchRow())
129:                 array_push($strToReturn, $strRowArray[0]);
130:             return $strToReturn;
131:         }
132:         
133:         public function GetFieldsForTable($strTableName) {
134:             $objResult = $this->Query(sprintf('SELECT * FROM %s%s%s LIMIT 1', $this->strEscapeIdentifierBegin, $strTableName, $this->strEscapeIdentifierEnd));
135:             return $objResult->FetchFields();
136:         }
137: 
138:         public function InsertId($strTableName = null, $strColumnName = null) {
139:             return $this->objMySqli->insert_id;
140:         }
141: 
142:         public function Close() {
143:             $this->objMySqli->close();
144: 
145:             // Update Connected Flag
146:             $this->blnConnectedFlag = false;
147:         }
148: 
149:         protected function ExecuteTransactionBegin() {
150:             // Set to AutoCommit
151:             $this->NonQuery('SET AUTOCOMMIT=0;');
152:         }
153: 
154:         protected function ExecuteTransactionCommit() {
155:             $this->NonQuery('COMMIT;');
156:             // Set to AutoCommit
157:             $this->NonQuery('SET AUTOCOMMIT=1;');
158:         }
159: 
160:         protected function ExecuteTransactionRollBack() {
161:             $this->NonQuery('ROLLBACK;');
162:             // Set to AutoCommit
163:             $this->NonQuery('SET AUTOCOMMIT=1;');
164:         }
165: 
166:         public function GetFoundRows() {
167:             if (array_key_exists('usefoundrows', $this->objConfigArray) && $this->objConfigArray['usefoundrows']) {
168:                 $objResult = $this->Query('SELECT FOUND_ROWS();');
169:                 $strRow = $objResult->FetchArray();
170:                 return $strRow[0];
171:             } else
172:                 throw new QCallerException('Cannot call GetFoundRows() on the database when "usefoundrows" configuration was not set to true.');
173:         }
174: 
175:         public function GetIndexesForTable($strTableName) {
176:             // Figure out the Table Type (InnoDB, MyISAM, etc.) by parsing the Create Table description
177:             $strCreateStatement = $this->GetCreateStatementForTable($strTableName);
178:             $strTableType = $this->GetTableTypeForCreateStatement($strCreateStatement);
179: 
180:             switch (true) {
181:                 case substr($strTableType, 0, 6) == 'MYISAM':
182:                     return $this->ParseForIndexes($strCreateStatement);
183: 
184:                 case substr($strTableType, 0, 6) == 'INNODB':
185:                     return $this->ParseForIndexes($strCreateStatement);
186: 
187:                 case substr($strTableType, 0, 6) == 'MEMORY':
188:                 case substr($strTableType, 0, 4) == 'HEAP':
189:                     return $this->ParseForIndexes($strCreateStatement);
190: 
191:                 default:
192:                     throw new Exception("Table Type is not supported: $strTableType");
193:             }
194:         }
195: 
196:         public function GetForeignKeysForTable($strTableName) {
197:             // Figure out the Table Type (InnoDB, MyISAM, etc.) by parsing the Create Table description
198:             $strCreateStatement = $this->GetCreateStatementForTable($strTableName);
199:             $strTableType = $this->GetTableTypeForCreateStatement($strCreateStatement);
200: 
201:             switch (true) {
202:                 case substr($strTableType, 0, 6) == 'MYISAM':
203:                     $objForeignKeyArray = array();
204:                     break;
205: 
206:                 case substr($strTableType, 0, 6) == 'MEMORY':
207:                 case substr($strTableType, 0, 4) == 'HEAP':
208:                     $objForeignKeyArray = array();
209:                     break;
210: 
211:                 case substr($strTableType, 0, 6) == 'INNODB':
212:                     $objForeignKeyArray = $this->ParseForInnoDbForeignKeys($strCreateStatement);
213:                     break;
214: 
215:                 default:
216:                     throw new Exception("Table Type is not supported: $strTableType");
217:             }
218: 
219:             return $objForeignKeyArray;
220:         }
221: 
222:         // MySql defines KeyDefinition to be [OPTIONAL_NAME] ([COL], ...)
223:         // If the key name exists, this will parse it out and return it
224:         private function ParseNameFromKeyDefinition($strKeyDefinition) {
225:             $strKeyDefinition = trim($strKeyDefinition);
226: 
227:             $intPosition = strpos($strKeyDefinition, '(');
228: 
229:             if ($intPosition === false)
230:                 throw new Exception("Invalid Key Definition: $strKeyDefinition");
231:             else if ($intPosition == 0)
232:                 // No Key Name Defined
233:                 return null;
234:             
235:             // If we're here, then we have a key name defined
236:             $strName = trim(substr($strKeyDefinition, 0, $intPosition));
237:             
238:             // Rip Out leading and trailing "`" character (if applicable)
239:             if (substr($strName, 0, 1) == '`')
240:                 return substr($strName, 1, strlen($strName) - 2);
241:             else
242:                 return $strName;
243:         }
244: 
245:         // MySql defines KeyDefinition to be [OPTIONAL_NAME] ([COL], ...)
246:         // This will return an array of strings that are the names [COL], etc.
247:         private function ParseColumnNameArrayFromKeyDefinition($strKeyDefinition) {
248:             $strKeyDefinition = trim($strKeyDefinition);
249:             
250:             // Get rid of the opening "(" and the closing ")"
251:             $intPosition = strpos($strKeyDefinition, '(');
252:             if ($intPosition === false)
253:                 throw new Exception("Invalid Key Definition: $strKeyDefinition");
254:             $strKeyDefinition = trim(substr($strKeyDefinition, $intPosition + 1));
255: 
256:             $intPosition = strpos($strKeyDefinition, ')');
257:             if ($intPosition === false)
258:                 throw new Exception("Invalid Key Definition: $strKeyDefinition");
259:             $strKeyDefinition = trim(substr($strKeyDefinition, 0, $intPosition));
260: 
261:             // Create the Array
262:             // TODO: Current method doesn't support key names with commas or parenthesis in them!
263:             $strToReturn = explode(',', $strKeyDefinition);
264: 
265:             // Take out trailing and leading "`" character in each name (if applicable)
266:             for ($intIndex = 0; $intIndex < count($strToReturn); $intIndex++) {
267:                 $strColumn = $strToReturn[$intIndex];
268: 
269:                 if (substr($strColumn, 0, 1) == '`')
270:                     $strColumn = substr($strColumn, 1, strpos($strColumn, '`', 1) - 1);
271: 
272:                 $strToReturn[$intIndex] = $strColumn;
273:             }
274: 
275:             return $strToReturn;
276:         }
277: 
278:         private function ParseForIndexes($strCreateStatement) {
279:             // MySql nicely splits each object in a table into it's own line
280:             // Split the create statement into lines, and then pull out anything
281:             // that says "PRIMARY KEY", "UNIQUE KEY", or just plain ol' "KEY"
282:             $strLineArray = explode("\n", $strCreateStatement);
283: 
284:             $objIndexArray = array();
285:             
286:             // We don't care about the first line or the last line
287:             for ($intIndex = 1; $intIndex < (count($strLineArray) - 1); $intIndex++) {
288:                 $strLine = $strLineArray[$intIndex];
289: 
290:                 // Each object has a two-space indent
291:                 // So this is a key object if any of those key-related words exist at position 2
292:                 switch (2) {
293:                     case (strpos($strLine, 'PRIMARY KEY')):
294:                         $strKeyDefinition = substr($strLine, strlen('  PRIMARY KEY '));
295: 
296:                         $strKeyName = $this->ParseNameFromKeyDefinition($strKeyDefinition);
297:                         $strColumnNameArray = $this->ParseColumnNameArrayFromKeyDefinition($strKeyDefinition);
298: 
299:                         $objIndex = new QDatabaseIndex($strKeyName, $blnPrimaryKey = true, $blnUnique = true, $strColumnNameArray);
300:                         array_push($objIndexArray, $objIndex);
301:                         break;
302: 
303:                     case (strpos($strLine, 'UNIQUE KEY')):
304:                         $strKeyDefinition = substr($strLine, strlen('  UNIQUE KEY '));
305: 
306:                         $strKeyName = $this->ParseNameFromKeyDefinition($strKeyDefinition);
307:                         $strColumnNameArray = $this->ParseColumnNameArrayFromKeyDefinition($strKeyDefinition);
308: 
309:                         $objIndex = new QDatabaseIndex($strKeyName, $blnPrimaryKey = false, $blnUnique = true, $strColumnNameArray);
310:                         array_push($objIndexArray, $objIndex);
311:                         break;
312: 
313:                     case (strpos($strLine, 'KEY')):
314:                         $strKeyDefinition = substr($strLine, strlen('  KEY '));
315: 
316:                         $strKeyName = $this->ParseNameFromKeyDefinition($strKeyDefinition);
317:                         $strColumnNameArray = $this->ParseColumnNameArrayFromKeyDefinition($strKeyDefinition);
318: 
319:                         $objIndex = new QDatabaseIndex($strKeyName, $blnPrimaryKey = false, $blnUnique = false, $strColumnNameArray);
320:                         array_push($objIndexArray, $objIndex);
321:                         break;
322:                 }
323:             }
324: 
325:             return $objIndexArray;
326:         }
327: 
328:         private function ParseForInnoDbForeignKeys($strCreateStatement) {
329:             // MySql nicely splits each object in a table into it's own line
330:             // Split the create statement into lines, and then pull out anything
331:             // that starts with "CONSTRAINT" and contains "FOREIGN KEY"
332:             $strLineArray = explode("\n", $strCreateStatement);
333: 
334:             $objForeignKeyArray = array();
335: 
336:             // We don't care about the first line or the last line
337:             for ($intIndex = 1; $intIndex < (count($strLineArray) - 1); $intIndex++) {
338:                 $strLine = $strLineArray[$intIndex];
339: 
340:                 // Check to see if the line:
341:                 // * Starts with "CONSTRAINT" at position 2 AND
342:                 // * contains "FOREIGN KEY"
343:                 if ((strpos($strLine, "CONSTRAINT") == 2) &&
344:                     (strpos($strLine, "FOREIGN KEY") !== false)) {
345:                     $strLine = substr($strLine, strlen('  CONSTRAINT '));
346:                     
347:                     // By the end of the following lines, we will end up with a strTokenArray
348:                     // Index 0: the FK name
349:                     // Index 1: the list of columns that are the foreign key
350:                     // Index 2: the table which this FK references
351:                     // Index 3: the list of columns which this FK references
352:                     $strTokenArray = explode(' FOREIGN KEY ', $strLine);
353:                     $strTokenArray[1] = explode(' REFERENCES ', $strTokenArray[1]);
354:                     $strTokenArray[2] = $strTokenArray[1][1];
355:                     $strTokenArray[1] = $strTokenArray[1][0];
356:                     $strTokenArray[2] = explode(' ', $strTokenArray[2]);
357:                     $strTokenArray[3] = $strTokenArray[2][1];
358:                     $strTokenArray[2] = $strTokenArray[2][0];
359:                     
360:                     // Cleanup, and change Index 1 and Index 3 to be an array based on the
361:                     // parsed column name list
362:                     if (substr($strTokenArray[0], 0, 1) == '`')
363:                         $strTokenArray[0] = substr($strTokenArray[0], 1, strlen($strTokenArray[0]) - 2);
364:                     $strTokenArray[1] = $this->ParseColumnNameArrayFromKeyDefinition($strTokenArray[1]);
365:                     if (substr($strTokenArray[2], 0, 1) == '`')
366:                         $strTokenArray[2] = substr($strTokenArray[2], 1, strlen($strTokenArray[2]) - 2);
367:                     $strTokenArray[3] = $this->ParseColumnNameArrayFromKeyDefinition($strTokenArray[3]);
368:                     
369:                     // Create the FK object and add it to the return array
370:                     $objForeignKey = new QDatabaseForeignKey($strTokenArray[0], $strTokenArray[1], $strTokenArray[2], $strTokenArray[3]);
371:                     array_push($objForeignKeyArray, $objForeignKey);
372:                     
373:                     // Ensure the FK object has matching column numbers (or else, throw)
374:                     if ((count($objForeignKey->ColumnNameArray) == 0) ||
375:                         (count($objForeignKey->ColumnNameArray) != count($objForeignKey->ReferenceColumnNameArray)))
376:                         throw new Exception("Invalid Foreign Key definition: $strLine");
377:                 }
378:             }
379:             return $objForeignKeyArray;
380:         }
381: 
382:         private function GetCreateStatementForTable($strTableName) {
383:             // Use the MySQL "SHOW CREATE TABLE" functionality to get the table's Create statement
384:             $objResult = $this->Query(sprintf('SHOW CREATE TABLE `%s`', $strTableName));
385:             $objRow = $objResult->FetchRow();
386:             $strCreateTable = $objRow[1];
387:             $strCreateTable = str_replace("\r", "", $strCreateTable);
388:             return $strCreateTable;
389:         }
390: 
391:         private function GetTableTypeForCreateStatement($strCreateStatement) {
392:             // Table Type is in the last line of the Create Statement, "TYPE=DbTableType"
393:             $strLineArray = explode("\n", $strCreateStatement);
394:             $strFinalLine = strtoupper($strLineArray[count($strLineArray) - 1]);
395: 
396:             if (substr($strFinalLine, 0, 7) == ') TYPE=') {
397:                 return trim(substr($strFinalLine, 7));
398:             } else if (substr($strFinalLine, 0, 9) == ') ENGINE=') {
399:                 return trim(substr($strFinalLine, 9));
400:             } else
401:                 throw new Exception("Invalid Table Description");
402:         }
403: 
404:         /**
405:          * 
406:          * @param string $sql
407:          * @return QMySqliDatabaseResult
408:          */
409:         public function ExplainStatement($sql) {
410:             // As of MySQL 5.6.3, EXPLAIN provides information about
411:             // SELECT, DELETE, INSERT, REPLACE, and UPDATE statements.
412:             // Before MySQL 5.6.3, EXPLAIN provides information only about SELECT statements.
413:             
414:             $objDbResult = $this->Query("select version()");
415:             $strDbRow = $objDbResult->FetchRow();
416:             $strVersion = QType::Cast($strDbRow[0], QType::String);
417:             $strVersionArray = explode('.', $strVersion);
418:             $strMajorVersion = null;
419:             if (count($strVersionArray) > 0) {
420:                 $strMajorVersion = $strVersionArray[0];
421:             }
422:             if (null === $strMajorVersion) {
423:                 return null;
424:             }
425:             if (intval($strMajorVersion) > 5) {
426:                 return $this->Query("EXPLAIN " . $sql);
427:             } else if (5 == intval($strMajorVersion)) {
428:                 $strMinorVersion = null;
429:                 if (count($strVersionArray) > 1) {
430:                     $strMinorVersion = $strVersionArray[1];
431:                 }
432:                 if (null === $strMinorVersion) {
433:                     return null;
434:                 }
435:                 if (intval($strMinorVersion) > 6) {
436:                     return $this->Query("EXPLAIN " . $sql);
437:                 } else if (6 == intval($strMinorVersion)) {
438:                     $strSubMinorVersion = null;
439:                     if (count($strVersionArray) > 2) {
440:                         $strSubMinorVersion = $strVersionArray[2];
441:                     }
442:                     if (null === $strSubMinorVersion) {
443:                         return null;
444:                     }
445:                     if (!is_integer($strSubMinorVersion)) {
446:                         $strSubMinorVersionArray = explode("-", $strSubMinorVersion);
447:                         if (count($strSubMinorVersionArray) > 1) {
448:                            $strSubMinorVersion = $strSubMinorVersionArray[0];
449:                            if (!is_integer($strSubMinorVersion)) {
450:                                // Failed to determine the sub-minor version.
451:                                return null;
452:                            }
453:                         } else {
454:                             // Failed to determine the sub-minor version.
455:                             return null;
456:                         }
457:                     }
458:                     if (intval($strSubMinorVersion) > 2) {
459:                         return $this->Query("EXPLAIN " . $sql);
460:                     } else {
461:                         // We have the version before 5.6.3
462:                         // let's check if it is SELECT-only request
463:                         if (0 == substr_count($sql, "DELETE") &&
464:                             0 == substr_count($sql, "INSERT") &&
465:                             0 == substr_count($sql, "REPLACE") &&
466:                             0 == substr_count($sql, "UPDATE")
467:                         ) {
468:                             return $this->Query("EXPLAIN " . $sql);
469:                         }
470:                     }
471:                 }
472:             }
473:             // Return null by default
474:             return null;
475:         }
476:     }
477: 
478:     /**
479:      *
480:      * @package DatabaseAdapters
481:      */
482:     class QMySqliDatabaseException extends QDatabaseExceptionBase {
483:         public function __construct($strMessage, $intNumber, $strQuery) {
484:             parent::__construct(sprintf("MySqli Error: %s", $strMessage), 2);
485:             $this->intErrorNumber = $intNumber;
486:             $this->strQuery = $strQuery;
487:         }
488:     }
489: 
490:     /**
491:      * Class to handle results sent by database upon querying
492:      * @package DatabaseAdapters
493:      */
494:     class QMySqliDatabaseResult extends QDatabaseResultBase {
495:         protected $objMySqliResult;
496:         protected $objDb;
497: 
498:         public function __construct(mysqli_result $objResult, QMySqliDatabase $objDb) {
499:             $this->objMySqliResult = $objResult;
500:             $this->objDb = $objDb;
501:         }
502: 
503:         public function FetchArray() {
504:             return $this->objMySqliResult->fetch_array();
505:         }
506: 
507:         public function FetchFields() {
508:             $objArrayToReturn = array();
509:             while ($objField = $this->objMySqliResult->fetch_field())
510:                 array_push($objArrayToReturn, new QMySqliDatabaseField($objField, $this->objDb));
511:             return $objArrayToReturn;
512:         }
513: 
514:         public function FetchField() {
515:             if ($objField = $this->objMySqliResult->fetch_field())
516:                 return new QMySqliDatabaseField($objField, $this->objDb);
517:         }
518: 
519:         public function FetchRow() {
520:             return $this->objMySqliResult->fetch_row();
521:         }
522: 
523:         public function MySqlFetchField() {
524:             return $this->objMySqliResult->fetch_field();
525:         }
526: 
527:         public function CountRows() {
528:             return $this->objMySqliResult->num_rows;
529:         }
530: 
531:         public function CountFields() {
532:             return $this->objMySqliResult->num_fields();
533:         }
534: 
535:         public function Close() {
536:             $this->objMySqliResult->free();
537:         }
538:         
539:         public function GetNextRow() {
540:             $strColumnArray = $this->FetchArray();
541:             
542:             if ($strColumnArray)
543:                 return new QMySqliDatabaseRow($strColumnArray);
544:             else
545:                 return null;
546:         }
547: 
548:         public function GetRows() {
549:             $objDbRowArray = array();
550:             while ($objDbRow = $this->GetNextRow())
551:                 array_push($objDbRowArray, $objDbRow);
552:             return $objDbRowArray;
553:         }
554:     }
555: 
556:     /**
557:      *
558:      * @package DatabaseAdapters
559:      */
560:     class QMySqliDatabaseRow extends QDatabaseRowBase {
561:         protected $strColumnArray;
562: 
563:         public function __construct($strColumnArray) {
564:             $this->strColumnArray = $strColumnArray;
565:         }
566: 
567:         /**
568:          * Gets the value of a column from a result row returned by the database
569:          *
570:          * @param string        $strColumnName Name of the column
571:          * @param null|string   $strColumnType A QDatabaseFieldType string
572:          *
573:          * @return mixed
574:          */
575:         public function GetColumn($strColumnName, $strColumnType = null) {
576:             if (!isset($this->strColumnArray[$strColumnName])) {
577:                 return null;
578:             }
579:             $strColumnValue = $this->strColumnArray[$strColumnName];
580: 
581:             switch ($strColumnType) {
582:                 case QDatabaseFieldType::Bit:
583:                     // Account for single bit value
584:                     $chrBit = $strColumnValue;
585:                     if ((strlen($chrBit) == 1) && (ord($chrBit) == 0))
586:                         return false;
587: 
588:                     // Otherwise, use PHP conditional to determine true or false
589:                     return ($strColumnValue) ? true : false;
590: 
591:                 case QDatabaseFieldType::Blob:
592:                 case QDatabaseFieldType::Char:
593:                 case QDatabaseFieldType::VarChar:
594:                     return QType::Cast($strColumnValue, QType::String);
595: 
596:                 case QDatabaseFieldType::Date:
597:                     return new QDateTime($strColumnValue, null, QDateTime::DateOnlyType);
598:                 case QDatabaseFieldType::DateTime:
599:                     return new QDateTime($strColumnValue, null, QDateTime::DateAndTimeType);
600:                 case QDatabaseFieldType::Time:
601:                     return new QDateTime($strColumnValue, null, QDateTime::TimeOnlyType);
602: 
603:                 case QDatabaseFieldType::Float:
604:                     return QType::Cast($strColumnValue, QType::Float);
605: 
606:                 case QDatabaseFieldType::Integer:
607:                     return QType::Cast($strColumnValue, QType::Integer);
608: 
609:                 default:
610:                     return $strColumnValue;
611:             }
612:         }
613: 
614:         /**
615:          * Tells whether a particular column exists in a returned database row
616:          *
617:          * @param string $strColumnName Name of te column
618:          *
619:          * @return bool
620:          */
621:         public function ColumnExists($strColumnName) {
622:             return array_key_exists($strColumnName, $this->strColumnArray);
623:         }
624: 
625:         public function GetColumnNameArray() {
626:             return $this->strColumnArray;
627:         }
628:     }
629: 
630:     /**
631:      *
632:      * @package DatabaseAdapters
633:      */
634:     class QMySqliDatabaseField extends QDatabaseFieldBase {
635:         public function __construct($mixFieldData, $objDb = null) {
636:             $this->strName = $mixFieldData->name;
637:             $this->strOriginalName = $mixFieldData->orgname;
638:             $this->strTable = $mixFieldData->table;
639:             $this->strOriginalTable = $mixFieldData->orgtable;
640:             $this->strDefault = $mixFieldData->def;
641:             $this->intMaxLength = null;
642:             $this->strComment = null;
643: 
644:             // Set strOriginalName to Name if it isn't set
645:             if (!$this->strOriginalName)
646:                 $this->strOriginalName = $this->strName;
647:             
648:             if($this->strOriginalTable)
649:             {
650:                 $objDescriptionResult = $objDb->Query(sprintf("SHOW FULL FIELDS FROM `%s`", $this->strOriginalTable));
651:                 while (($objRow = $objDescriptionResult->FetchArray())) {
652:                     if ($objRow["Field"] == $this->strOriginalName) {
653:                         
654:                         $this->strDefault = $objRow["Default"]; 
655:                         // Calculate MaxLength of this column (e.g. if it's a varchar, calculate length of varchar
656:                         // NOTE: $mixFieldData->max_length in the MySQL spec is **DIFFERENT**
657:                         $strLengthArray = explode("(", $objRow["Type"]);
658:                         if ((count($strLengthArray) > 1) &&
659:                             (strtolower($strLengthArray[0]) != 'enum') &&
660:                             (strtolower($strLengthArray[0]) != 'set')) {
661:                             $strLengthArray = explode(")", $strLengthArray[1]);
662:                             $this->intMaxLength = $strLengthArray[0];
663: 
664:                             // If the length is something like (7,2), then let's pull out just the "7"
665:                             $intCommaPosition = strpos($this->intMaxLength, ',');
666:                             if ($intCommaPosition !== false) {
667:                                 $this->intMaxLength = substr($this->intMaxLength, 0, $intCommaPosition);
668:                                 $this->intMaxLength++; // this is a decimal, so max length should include the decimal point too.
669:                             }
670: 
671:                             if (!is_numeric($this->intMaxLength)) {
672:                                 throw new Exception("Not a valid Column Length: " . $objRow["Type"]);
673:                             }
674:                         }
675:                         
676:                         // Get the field comment
677:                         $this->strComment = $objRow["Comment"];
678:                     }
679:                 }
680:             }
681: 
682:             $this->blnIdentity = ($mixFieldData->flags & MYSQLI_AUTO_INCREMENT_FLAG) ? true: false;
683:             $this->blnNotNull = ($mixFieldData->flags & MYSQLI_NOT_NULL_FLAG) ? true : false;
684:             $this->blnPrimaryKey = ($mixFieldData->flags & MYSQLI_PRI_KEY_FLAG) ? true : false;
685:             $this->blnUnique = ($mixFieldData->flags & MYSQLI_UNIQUE_KEY_FLAG) ? true : false;
686:             
687:             $this->SetFieldType($mixFieldData->type);
688: 
689:             // Special situation that we take advantage of to automatically implement optimistic locking
690:             if ($mixFieldData->type == MYSQLI_TYPE_TIMESTAMP &&
691:                     $mixFieldData->flags & MYSQLI_ON_UPDATE_NOW_FLAG) {
692:                 $this->strType = QDatabaseFieldType::VarChar;
693:                 $this->blnTimestamp = true;
694:             }
695:         }
696: 
697:         protected function SetFieldType($intMySqlFieldType) {
698: 
699:             if (version_compare(PHP_VERSION, '5.6.15') >= 0) {
700:                 if ($intMySqlFieldType == MYSQLI_TYPE_JSON) {
701:                     $this->strType = QDatabaseFieldType::Json;
702:                     return;
703:                 }
704:             }
705:             switch ($intMySqlFieldType) {
706:                 case MYSQLI_TYPE_TINY:
707:                     if ($this->intMaxLength == 1)
708:                         $this->strType = QDatabaseFieldType::Bit;
709:                     else
710:                         $this->strType = QDatabaseFieldType::Integer;
711:                     break;
712:                 case MYSQLI_TYPE_SHORT:
713:                 case MYSQLI_TYPE_LONG:
714:                 case MYSQLI_TYPE_LONGLONG:
715:                 case MYSQLI_TYPE_INT24:
716:                     $this->strType = QDatabaseFieldType::Integer;
717:                     break;
718:                 case MYSQLI_TYPE_NEWDECIMAL:
719:                 case MYSQLI_TYPE_DECIMAL:
720:                     // NOTE: PHP's best response to fixed point exact precision numbers is to use the bcmath library.
721:                     // bcmath requires string inputs. If you try to do math directly on these, PHP will convert to float,
722:                     // so for those who care, they will need to be careful. For those who do not care, then PHP will do
723:                     // the conversion anyway.
724:                     $this->strType = QDatabaseFieldType::VarChar;
725:                     break;
726: 
727:                 case MYSQLI_TYPE_FLOAT:
728:                     $this->strType = QDatabaseFieldType::Float;
729:                     break;
730:                 case MYSQLI_TYPE_DOUBLE:
731:                     // NOTE: PHP does not offer full support of double-precision floats.
732:                     // Value will be set as a VarChar which will guarantee that the precision will be maintained.
733:                     //    However, you will not be able to support full typing control (e.g. you would
734:                     //    not be able to use a QFloatTextBox -- only a regular QTextBox)
735:                     $this->strType = QDatabaseFieldType::VarChar;
736:                     break;
737:                 case MYSQLI_TYPE_DATE:
738:                     $this->strType = QDatabaseFieldType::Date;
739:                     break;
740:                 case MYSQLI_TYPE_TIME:
741:                     $this->strType = QDatabaseFieldType::Time;
742:                     break;
743:                 case MYSQLI_TYPE_TIMESTAMP:
744:                 case MYSQLI_TYPE_DATETIME:
745:                     $this->strType = QDatabaseFieldType::DateTime;
746:                     break;
747:                 case MYSQLI_TYPE_TINY_BLOB:
748:                 case MYSQLI_TYPE_MEDIUM_BLOB:
749:                 case MYSQLI_TYPE_LONG_BLOB:
750:                 case MYSQLI_TYPE_BLOB:
751:                     $this->strType = QDatabaseFieldType::Blob;
752:                     break;
753:                 case MYSQLI_TYPE_STRING:
754:                 case MYSQLI_TYPE_VAR_STRING:
755:                     $this->strType = QDatabaseFieldType::VarChar;
756:                     break;
757:                 case MYSQLI_TYPE_CHAR:
758:                     $this->strType = QDatabaseFieldType::Char;
759:                     break;
760:                 case MYSQLI_TYPE_INTERVAL:
761:                     throw new Exception("QCubed MySqliDatabase library: MYSQLI_TYPE_INTERVAL is not supported");
762:                     break;
763:                 case MYSQLI_TYPE_NULL:
764:                     throw new Exception("QCubed MySqliDatabase library: MYSQLI_TYPE_NULL is not supported");
765:                     break;
766:                 case MYSQLI_TYPE_YEAR:
767:                     $this->strType = QDatabaseFieldType::Integer;
768:                     break;
769:                 case MYSQLI_TYPE_NEWDATE:
770:                     throw new Exception("QCubed MySqliDatabase library: MYSQLI_TYPE_NEWDATE is not supported");
771:                     break;
772:                 case MYSQLI_TYPE_ENUM:
773:                     throw new Exception("QCubed MySqliDatabase library: MYSQLI_TYPE_ENUM is not supported.  Use TypeTables instead.");
774:                     break;
775:                 case MYSQLI_TYPE_SET:
776:                     throw new Exception("QCubed MySqliDatabase library: MYSQLI_TYPE_SET is not supported.  Use TypeTables instead.");
777:                     break;
778:                 case MYSQLI_TYPE_GEOMETRY:
779:                     throw new Exception("QCubed MySqliDatabase library: MYSQLI_TYPE_GEOMETRY is not supported");
780:                     break;
781:                 default:
782:                     throw new Exception("Unable to determine MySqli Database Field Type: " . $intMySqlFieldType);
783:                     break;
784:             }
785:         }
786:     }
API documentation generated by ApiGen