Ferreteria/v2/usage/db/records: Difference between revisions
< Ferreteria | v2 | usage | db
Jump to navigation
Jump to search
(I think that's what I wanted to be able to remember for next time.) |
m (5 revisions imported: moving this project here) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 14: | Line 14: | ||
* <code>public function GetUpdateStorageOverrides()</code> defaults to array() | * <code>public function GetUpdateStorageOverrides()</code> defaults to array() | ||
Notes: | |||
* All of the override functions currently output in '''stored''' format (typically SQL) rather than raw/native '''value''' format, so strings must be escaped and quoted. | |||
* [[../../forms|Forms]] don't currently use the Recordset version of <code>Save()</code> but implement their own version (<code>public function SaveRecord(array $arStor)</code>), which is why these functions need to be public. Possibly this methodology should be re-examined; if it's necessary, document why. | |||
==Method Index== | ==Method Index== | ||
* <code>ftName_forTable</code> | * <code>ftName_forTable</code> |
Latest revision as of 16:45, 22 May 2022
The top layer of routines for writing data from a recordset object back to the database is pretty simple and consists of two main functions:
- table:
public function Insert(array $arData)
- table:
public function Update(array $arChg,$sqlWhere,$isNativeData=FALSE)
- recordset:
public function Update(array $arChg,$isNativeData=FALSE)
The Save()
function adds some automation by detecting whether an Insert() or Update() is needed and automatically figuring out which fields need to be written (and only updating those fields, to minimize database server usage). This involves several additional functions, some of which are intended to be overridden:
protected function FigureSQL_forInsert(array $arData)
public function FigureSQL_forUpdate(array $arChg,$sqlWhere,$isNativeData=self::KFMT_NATIVE)
public function ChangeFieldValues(array $ar)
public function GetStorableValues_Changed()
public function GetStorableValues_toInsert()
defaults toGetStorableValues_Changed()
public function GetStorableValues_toUpdate()
defaults toGetStorableValues_Changed()
public function GetInsertStorageOverrides()
defaults to array()public function GetUpdateStorageOverrides()
defaults to array()
Notes:
- All of the override functions currently output in stored format (typically SQL) rather than raw/native value format, so strings must be escaped and quoted.
- Forms don't currently use the Recordset version of
Save()
but implement their own version (public function SaveRecord(array $arStor)
), which is why these functions need to be public. Possibly this methodology should be re-examined; if it's necessary, document why.
Method Index
ftName_forTable
protected function FigureSQL_forInsert(array $arData)
public function FigureSQL_forUpdate(array $arChg,$sqlWhere,$isNativeData=self::KFMT_NATIVE)
trait ftWriteableTable
public function Insert(array $arData)
public function Update(array $arChg,$sqlWhere,$isNativeData=FALSE)
trait ftSaveableRecord
protected function TouchField($sKey)
protected function TouchedArray()
public function ChangeFieldValues(array $ar)
public function GetStorableValues_Changed()
public function GetStorableValues_toInsert()
defaults toGetStorableValues_Changed()
public function GetStorableValues_toUpdate()
defaults toGetStorableValues_Changed()
public function GetInsertStorageOverrides()
defaults to array()public function GetUpdateStorageOverrides()
defaults to array()public function SetFieldValue($sKey,$val)
adds call to TouchField()public function Save($arSave=NULL)