Table of Contents
- ๐ฆ Class axelhahn\pdo_db_attachments
- ๐ถ Properties
-
๐ท Methods
- ๐น public __construct()
- ๐น public hookActions()
- ๐น public getRelativePath()
- ๐น public uploadFile()
- ๐น public storeNewFile()
- ๐น public attachmentPreview()
- ๐น public setUploadDir()
- ๐น public setUrlBase()
- ๐น public getTablename()
- ๐น public makeQuery()
- ๐น public verifyColumns()
- ๐น public new()
- ๐น public create()
- ๐น public read()
- ๐น public readByFields()
- ๐น public _relGetTargetIds()
- ๐น public relSync()
- ๐น public update()
- ๐น public delete()
- ๐น public flush()
- ๐น public save()
- ๐น public relCreate()
- ๐น public relRead()
- ๐น public relReadLookupItem()
- ๐น public relDelete()
- ๐น public relDeleteAll()
- ๐น public relFlush()
- ๐น public count()
- ๐น public get()
- ๐น public getAttributes()
- ๐น public getBasicAttributes()
- ๐น public getDescriptionLine()
- ๐น public getLabel()
- ๐น public getRelLabel()
- ๐น public getItem()
- ๐น public getFormtype()
- ๐น public hasChange()
- ๐น public id()
- ๐น public getTable()
- ๐น public search()
- ๐น public validate()
- ๐น public set()
- ๐น public setItem()
๐ฆ Class axelhahn\pdo_db_attachments
๐ถ Properties
(none)
๐ท Methods
๐น public __construct()
Constructor
Line 43 (4 lines)
Return: void
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $oDB | axelhahn\pdo_db |
pdo_db $oDB instance of database object class |
๐น public hookActions()
Get array of all hook actions Keys:
- backend_preview {string} method name for preview in AxelOM
-
{string} method name four your custom action
Line 63 (8 lines)
Return: array
Parameters: 0 (required: 0)
๐น public getRelativePath()
Get relative path of a file with full path relative to upload base dir Used in storeNewFile()
Line 80 (4 lines)
Return: string
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $FileWithFullPath | string |
filename |
๐น public uploadFile()
Upload files given by $_FILES from a form and optionally create a relation to a given target object
see pages/object.php
Line 103 (66 lines)
Return: int|bool
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $aFile | array |
single array element of $_FILES which means |
- name {string} => filename, eg. my-image.png
- full_path {string} => ignored
- type {string} => MIME type eg. image/png
- tmp_name {string} => location of uploaded file eg. /tmp/php2hi7k4315in34bgFjGz/tmp/php2hi7k4315in34bgFjGz
- error {int} => error code, eg 0 for OK
- size {int} => filesize in byte eg. 312039
๐น public storeNewFile()
Add a file that is located in the upload base path as attachment object
Line 182 (25 lines)
Return: int|bool
Parameters: 2 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sFileWithFullPath | string |
|
| <optional> $aProperties | array |
array with settings to write; possible keys are |
- label
- description
- mime
- width
- height
๐น public attachmentPreview()
Get html code for attachment preview
Line 247 (49 lines)
Return: string
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $aOptions | array |
array of options; known keys: |
- baseurl {string} set base url for attachments that triggers -> setUrlBase(<baseurl>)
๐น public setUploadDir()
Sets the upload directory for the file attachments.
Line 307 (8 lines)
Return: bool
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sDir | string |
The directory path to set as the upload directory. |
๐น public setUrlBase()
Sets the base URL for the file attachments
Line 322 (4 lines)
Return: bool
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sUrl | string |
The base URL to set. |
๐น public getTablename()
Get a table name of a given class name @see reverse function _getObjectFromTablename()
Line 150 (4 lines)
Return: string
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $s | string |
input string to generate a table name from |
๐น public makeQuery()
Execute a sql statement a wrapper for $this->_pdo->makeQuery() that adds the current table
Line 193 (5 lines)
Return: array|bool
Parameters: 2 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sSql | string |
sql statement |
| <optional> $aData | array |
array with data items; if present prepare statement will be executed |
๐น public verifyColumns()
Verify database columns with current object configuration. It shows
- missing columns
- existing database columns that are not configured
- columns with wrong type
Line 284 (102 lines)
Return: array|bool
Parameters: 0 (required: 0)
๐น public new()
Generate a hash for a new empty item
Line 416 (13 lines)
Return: bool
Parameters: 0 (required: 0)
๐น public create()
Create a new entry in the database
Line 469 (30 lines)
Return: int|bool
Parameters: 0 (required: 0)
๐น public read()
Read an entry from database by known row id
Line 506 (8 lines)
Return: bool
Parameters: 2 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $iId | int |
row id to read |
| <optional> $bReadRelations | bool |
read relation too? default: false |
๐น public readByFields()
Read item from row by given fields with AND condition Useful for reading item by known uniq single or multiple column values
Line 523 (67 lines)
Return: bool
Parameters: 2 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $aColumns | array |
|
| <optional> $bReadRelations | bool |
๐น public _relGetTargetIds()
Get relations of the current item by given column It returns an array with [relation_id => id_of_target_column]
Line 598 (13 lines)
Return: array
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $sCol | string |
column name |
๐น public relSync()
Sync the relations of the current item to the relation table
- store new relations
- remove outdated relations
Line 619 (58 lines)
Return: bool
Parameters: 0 (required: 0)
๐น public update()
Update entry; the field โidโ is required to identify a single row in the table It returns false if the current item has no changes. It returns the id of the object if the update was successful
Line 684 (28 lines)
Return: int|bool
Parameters: 0 (required: 0)
๐น public delete()
Delete entry by a given id or current item
Line 718 (50 lines)
Return: bool
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $iId | int |
optional: id of the entry to delete; default: delete current item |
๐น public flush()
!!! DANGEROUS !!! Drop table of current object type. It deletes all items of a type and removes the schema from database
Line 780 (22 lines)
Return: bool
Parameters: 0 (required: 0)
๐น public save()
Save item. If id is set, update. Otherwise create.
Line 807 (6 lines)
Return: bool
Parameters: 0 (required: 0)
๐น public relCreate()
Create a relation from the current item to an id of a target object
Line 948 (74 lines)
Return: bool
Parameters: 3 (required: 2)
| Parameter | Type | Description |
|---|---|---|
| <required> $sToTable | string |
target object |
| <required> $iToId | int |
id of target object |
| <optional> $sFromColumn | ?string |
optional: source column |
๐น public relRead()
Get array with all relations of the current item
@see relReadLookupItem()
Line 1116 (24 lines)
Return: array
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $aFilter | array |
optional: filter existing relations by table and column |
Keys:
table => TARGETTABLE target table must match
column => COLNAME column name must match
๐น public relReadLookupItem()
Get array of referenced item of a lookup column
Line 1147 (16 lines)
Return: array
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sColumn | string |
name column that is a of the lookup column to another table |
๐น public relDelete()
Delete a single relation from current item
Line 1234 (12 lines)
Return: bool
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $iId | int |
optional: id of the relation to delete |
๐น public relDeleteAll()
Delete all relations of a single item called by delete(ID) before deleting the item itself
Line 1253 (24 lines)
Return: bool
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $iId | int |
if of an item; default: false (=current item) |
๐น public relFlush()
Delete all relations of current object type. Called by flush() before deleting all items of a type.
Line 1283 (8 lines)
Return: bool
Parameters: 0 (required: 0)
๐น public count()
Get count of existing items
Line 1299 (5 lines)
Return: int
Parameters: 0 (required: 0)
๐น public get()
Get a single property of an item. opposite function of set(KEY, VALUE)
Line 1311 (8 lines)
Return: mixed
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sKey2Get | string |
key of your object to set |
๐น public getAttributes()
Get array of attribute names
Line 1325 (6 lines)
Return: array
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $bWithValues | bool |
flag: including values? default: false |
๐น public getBasicAttributes()
Get array of main attributes to show in overview or to select a relation
Line 1336 (26 lines)
Return: array
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $bWithSortkey | bool |
๐น public getDescriptionLine()
Get a single line for a database row description
It fetches the basic attributes of the item and creates a single line string with values of the item, separated by dashes. If the item has no data, it returns false.
Line 1373 (19 lines)
Return: string|bool
Parameters: 1 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $aItem | array |
optional: item data; default: current item |
๐น public getLabel()
Get a label for the item. It fetches the basic attributes if needed. Alternatively it uses the id
Line 1402 (37 lines)
Return: string
Parameters: 2 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $aItem | array |
optional: item data; default: current item |
| <optional> $aColumns | array |
optional: array of columns to show; default: basic attributes |
๐น public getRelLabel()
For 1:1 lookups: get the label of the related item by a given column. It fetches the current value of the column and returns the label of the connected item of the lookup table
Line 1448 (5 lines)
Return: string|bool
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sColumn | string |
name of the lookup column |
๐น public getItem()
Get current item as an array
Line 1458 (4 lines)
Return: array
Parameters: 0 (required: 0)
๐น public getFormtype()
Return or guess the form type of a given attribute If $this->_aProperties[$sAttr][โattrโ] was defined then it returns that value. Otherwise the type will be guessed based on the attribute name or create statement.
Guess behaviour by create statement
- text -> textarea
- varchar -> input type text; maxsize is size of varchar
- varchar with more than 1024 byte -> textarea
If attribute starts with
- โcolorโ -> input with type โcolorโ
- โdateโ -> input with type โdateโ
- โdatetimeโ -> input with type โdatetime-localโ
- โemailโ -> input with type โemailโ
- โhtmlโ -> textarea with type โhtmlโ
- โmonthโ -> input with type โmonthโ !! check browser compatibility
- โnumberโ -> input with type โnumberโ
- โpasswordโ -> input with type โpasswordโ !! additional logic required
- โrangeโ -> input with type โrangeโ
- โtelโ -> input with type โtelโ
- โtimeโ -> input with type โtimeโ
- โurlโ -> input with type โurlโ
- โweekโ -> input with type โweekโ !! check browser compatibility
Line 1491 (205 lines)
Return: array|bool
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $sAttr | string |
name of the property |
๐น public hasChange()
Get bool if the current dataset item was changed
Line 1701 (5 lines)
Return: bool
Parameters: 0 (required: 0)
๐น public id()
Get id of the current item as integer it returns false if there is no id
Line 1712 (4 lines)
Return: int|bool
Parameters: 0 (required: 0)
๐น public getTable()
Get current table
Line 1721 (4 lines)
Return: string
Parameters: 0 (required: 0)
๐น public search()
Search for items in the current table
You should use โ:
Line 1743 (57 lines)
Return: array|bool
Parameters: 2 (required: 0)
| Parameter | Type | Description |
|---|---|---|
| <optional> $aOptions | array |
array with search options |
| - columns - array | string | |
| - where - array | string | |
| - order - array | string |
- limit - string
| <optional> $aData | array | array with values for prepared statement
๐น public validate()
Validate a new value to be set on a property and return bool for success
- The general fields (id, timecreated, timeupdated, delete) cannot be set.
- validate a field if validate_is set a type or auto detected by โcreateโ key in property
- validate a field if validate_regex set regex This method is called in set() but can be executed on its own
@see set() @throws \Exception
Line 1849 (77 lines)
Return: bool
Parameters: 2 (required: 2)
| Parameter | Type | Description |
|---|---|---|
| <required> $sKey2Set | string |
key of your object to set |
| <required> $value | mixed |
new value to set |
๐น public set()
Set a single property of an item.
- The general fields (id, timecreated, timeupdated, delete) cannot be set.
- validate a field if validate_is set a tyoe
- validate a field if validate_regex set regex Opposite function of get()
Line 1938 (26 lines)
Return: bool
Parameters: 2 (required: 2)
| Parameter | Type | Description |
|---|---|---|
| <required> $sKey2Set | string |
key of your object to set |
| <required> $value | mixed |
new value to set |
๐น public setItem()
Set new values for an item. The general fields (id, created, updated, delete) cannot be set. Opposite function if getItem()
Line 1972 (20 lines)
Return: bool
Parameters: 1 (required: 1)
| Parameter | Type | Description |
|---|---|---|
| <required> $aNewValues | array |
new values to set; a subset of this->_aItem |
Generated with Axels PHP class doc parser