BaseModel.php
system/BaseModel.php
1 class
72 methods
class BaseModel
The BaseModel class provides a number of convenient features that makes working with a databases less painful. Extending this class provide means of implementing various database systems It will: - simplifies pagination - allow specifying the return type (array, object, etc) with each call - automatically set and update timestamps - handle soft deletes - ensure validation is run against objects when saving items - process various callbacks - allow intermingling calls to the db connection
__construct
(?ValidationInterface $validation = null)
createDataConverter
()
useCasts
()
initialize
()
doFind
(bool $singleton, $id = null)
doFindColumn
(string $columnName)
doFindAll
(?int $limit = null, int $offset = 0)
doFirst
()
doInsert
(array $row)
doInsertBatch
(?array $set = null, ?bool $escape = null, int $batchSize = 100, bool $testing = false)
doUpdate
($id = null, $row = null)
doUpdateBatch
(?array $set = null, ?string $index = null, int $batchSize = 100, bool $returnSQL = false)
doDelete
($id = null, bool $purge = false)
doPurgeDeleted
()
doOnlyDeleted
()
doReplace
(?array $row = null, bool $returnSQL = false)
doErrors
()
getIdValue
($row)
countAllResults
(bool $reset = true, bool $test = false)
chunk
(int $size, Closure $userFunc)
find
($id = null)
findColumn
(string $columnName)
findAll
(?int $limit = null, int $offset = 0)
first
()
save
($row)
shouldUpdate
($row)
getInsertID
()
insert
($row = null, bool $returnID = true)
setCreatedField
(array $row, $date)
setUpdatedField
(array $row, $date)
insertBatch
(?array $set = null, ?bool $escape = null, int $batchSize = 100, bool $testing = false)
update
($id = null, $row = null)
updateBatch
(?array $set = null, ?string $index = null, int $batchSize = 100, bool $returnSQL = false)
delete
($id = null, bool $purge = false)
purgeDeleted
()
withDeleted
(bool $val = true)
onlyDeleted
()
replace
(?array $row = null, bool $returnSQL = false)
errors
(bool $forceDB = false)
paginate
(?int $perPage = null, string $group = 'default', ?int $page = null, int $segment = 0)
setAllowedFields
(array $allowedFields)
protect
(bool $protect = true)
doProtectFields
(array $row)
doProtectFieldsForInsert
(array $row)
setDate
(?int $userData = null)
intToDate
(int $value)
timeToDate
(Time $value)
skipValidation
(bool $skip = true)
setValidationMessages
(array $validationMessages)
setValidationMessage
(string $field, array $fieldMessages)
setValidationRules
(array $validationRules)
setValidationRule
(string $field, $fieldRules)
cleanRules
(bool $choice = false)
validate
($row)
getValidationRules
(array $options = [])
ensureValidation
()
getValidationMessages
()
cleanValidationRules
(array $rules, ?array $row = null)
allowCallbacks
(bool $val = true)
trigger
(string $event, array $eventData)
asArray
()
asObject
(string $class = 'object')
objectToArray
($object, bool $onlyChanged = true, bool $recursive = false)
timeToString
(array $properties)
Time
($value)
objectToRawArray
($object, bool $onlyChanged = true, bool $recursive = false)
transformDataToArray
($row, string $type)
__get
(string $name)
__isset
(string $name)
__call
(string $name, array $params)
allowEmptyInserts
(bool $value = true)
convertToReturnType
(array $row, string $returnType)