API Documentation for: 1.1.1
Show:

ObjectServiceItem Class

Namespace: Canteen\Services

The encapsulation of a single data type, requires a predefined data class and a table name and field definitions.

Constructor

ObjectServiceItem

(
  • className
  • table
  • field
  • itemName
  • itemsName
)

Parameters:

  • className String

    Class to bind database result to

  • table String

    The name of the database table

  • field Array

    The collection of ObjectServiceField objects

  • itemName String

    The name of the item

  • itemsName String

    The name of the plural items

Methods

defaultSingleName

() String private

Get the default single name

Returns:

String:

The name of a single item of this service

install

(
  • query
)
String

Experimental install feature to take the fields and convert them into a MySQL create table query.

Parameters:

  • query CreateQuery

    The query to install with

Returns:

String:

The sql query to install the table

orderByQuery

(
  • query
)
SelectQuery

Add order by fields to the select query

Parameters:

  • query SelectQuery

    The select database query

Returns:

SelectQuery:

The query object

setOrderBy

(
  • fieldName
  • [direction='asc']
)
ObjectService

A simple orderBy method to set the order of query

Parameters:

  • fieldName String

    The valid name of a field on this item

  • [direction='asc'] String optional

    The order by direction

Returns:

ObjectService:

The instance of this class, for chaining

setPrepends

(
  • maps
  • [value=null]
)
Dictionary

Get or set the collection of prepend prepends

Parameters:

  • maps Dictionary | String

    The map of prepends by field name or string of field name

  • [value=null] String optional

    The value if setting a single map

Returns:

Dictionary:

The prepends

setProperties

(
  • [props]
)

Get the select properties

Parameters:

  • [props] Array | String* optional

    N-number of strings to set as additional properties, or a collection of strings to add to the existing properties.

setWhere

(
  • args
)
ObjectService

Register additional where clauses for the SQL select on get methods

Parameters:

  • args Array | String*

    The collection of extra SQL select where parameters to add to all get selections

Returns:

ObjectService:

The instance of this class, for chaining

verify

(
  • fieldName
  • [value=null]
)
public

Convience method for the field validation wrapper for verify but call by name.

Parameters:

  • fieldName Dictionary | String

    The name of the field or a map of name=>values

  • [value=null] Mixed optional

    The value to check against

Properties

_fields

Array

The collection of ObjectServiceField objects

className

String

The name of the class to bind with

defaultField

ObjectServiceField

The main field, default

fieldsByName

Dictionary

The map of ObjectServiceField objects to their names

indexes

Dictionary

The map of field names that can be indexed

itemName

String

The name of the single item to use for dynamic method calls

itemsName

String

The name of multiple items to use for dynamic class

prepends

Dictionary

The property prepend prepends

properties

Array

The collection of mysql select properties

service

ObjectService

The reference to the service this originates on

table

String

The name of the table of the custom type

where

Array

Additional get where properties