๐Ÿ“ฆ 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 โ€œ:โ€ in your sql statements to use prepared statements

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