- Start
- License
- Framework
- First steps
- Updates
- XA_Functions
- WApp
- WAutoComplete
- WBasic
- WBasicCheckbox
- WBasicContext
- WBasicDateTime
- WBasicEdit
- WBasicEmail
- WBasicNumber
- WBasicRadio
- WBasicSelect
- WBasicSelectItem
- WBasicStyle
- WBreadcrumb
- WButton
- WCard
- WCarousel
- WCarouselImage
- WCarouselPanel
- WCheckbox
- WChip
- WCmpButtonIcon
- WCmpButtonSpinner
- WCmpNumericKeypad
- WCollapsible
- WCollapsiblePanel
- WCollection
- WCollectionItem
- WColor
- WContainer
- WContext
- WContextHelper
- WControl
- WCookie
- WCss
- WDatePicker
- WDateTime
- WDiv
- WDoc
- WDocSection
- WDropDownItem
- WDropdown
- WDump
- WEdit
- WEmail
- WEngine
- WFetch
- WFieldset
- WFile
- WFlexRow
- WFloatActionButton
- WFloatActionButtonItem
- WFooter
- WForm
- WHeader
- WIconGoogle
- WImage
- WInput
- WInputImage
- WInputMask
- WInputText
- WLabel
- WLink
- WList
- WListItem
- WMain
- WMariaDbDatasource
- WMariaDbQuery
- WMaterialBox
- WMaterializeContext
- WMaterializeHelper
- WMeta
- WModal
- WModalMsgBtn
- WModalObject
- WNav
- WNavbar
- WNavbarItem
- WNavbarLogo
- WNumber
- WPackage
- WPagination
- WPaginationItem
- WParagraph
- WPdf
- WPdfAutoTable
- WPdfAutoTableStyle
- WPdfStyle
- WPhpRunner
- WPostFile
- WPreloader
- WRadio
- WRadioMenu
- WRange
- WRouter
- WScript
- WSelect
- WSelectItem
- WSession
- WSidenav
- WSidenavHeader
- WSidenavItem
- WSimpleContext
- WSlider
- WSliderItem
- WSpan
- WSqliteDatasource
- WSqliteQuery
- WStyle
- WSwitch
- WSyntaxHilite
- WTable
- WTableCell
- WTableColGroup
- WTableRow
- WTableTask
- WTableZone
- WTabs
- WTabsItem
- WTask
- WText
- WTextArea
- WTimePicker
- WTooltip
- WTranslator
- WWaterContext
- WXailerMariaDbDatasource
- WXailerSqliteDatasource
- WXailerWebDatasource
WMariaDbDatasource
-
storage Datas
-
functions Methods
-
event Events
-
Inherits from: None
File: zMariaDbDatasource.prg
This class allows access to any database engine such as MariaDb or MySQL. It only uses the modules from Harbour's contributions area with some additions from xaWeb and therefore does not depend on any external library, as is the case with WXailerMariaDbDatasource, which depends on Xailer.
This class has been specifically designed for use in CGI environments and therefore lacks many of the features found in other classes for this same purpose. All of this, with the sole objective of gaining speed and ease of use.
Recordsets or cursors are very simple. They do not support inline editing, and you should consider them as what they are: simple arrays with all the data from the 'SELECT' operation you have performed. However, adding, editing, and deleting data is very easy to perform.
Any 'SELECT' type operation must be performed with the Query method, which returns an instance of the WMariaDbQuery class. This object has two fundamental members: the aData property and the Header method. The property returns an array with all the query data, and the method returns the name of each of the fields used.
For editing operations you must use the WMariaDbQuery:Record method and the WMariaDbQuery:SqlInsert and WMariaDbQuery:SqlUpdate methods. The Record method receives a single parameter with the record number you want to edit and returns a hash with the record data. If you want to perform an insertion operation you must indicate the value (0) as a parameter, which will return a hash with the default values for each of the fields. If you want a hash with all the values set to null you can use the (-1) parameter. This hash will be passed as a parameter to the WMariaDbQuery:SqlInsert method, and it will directly return the SQL statement to be used with the Execute method.
For editing, the procedure is very similar, but you have the option to execute the SQL statement only on the fields that have actually been modified. Use the Record method twice to retrieve the record to be edited. Edit only the first one, but when you construct the SQL statement with the WMariaDbQuery:SqlUpdate method, specify the additional hash you obtained in the second call to the Record method as the third parameter. The SqlUpdate method will construct the SQL statement with only the fields that have changed.
As you can imagine, the edit, insert, and delete operations you perform directly with the methods explained do not affect the recordset. If you want to continue working with that dataset after editing, you'll need to manually update it or trigger a reread by getting a new recordset. However, the WMariaDbQuery:LocalInsert and WMariaDbQuery:LocalUpdate methods make editing easier.
IMPORTANT NOTE:
You must include the libmariadbclient.a library in your projects. In Windows environments, you must also include libmariadb.dll in the folder where the CGI is located. In Linux environments, you must install the MariaDb-devel module with the following instruction:
sudo apt install libmariadb3 libmariadb-dev