Category
in package
Table of Contents
Methods
- categoryList() : mixed
- Return an array of IDs of categories a record is in.
- columnMain2joiner() : string
- Converts a main table name into a joiner column name.
- contains() : mixed
- Does a given category contatin a given record? Returns true if found, false otherwise
- create() : mixed
- Creates a category.
- insertInto() : bool
- Inserts a record into a category.
- lookup() : mixed
- Looks up a category.
- lookupOrCreate() : mixed
- Looks up a category. If not found, creates the category.
- name() : string|null
- recordList() : mixed
- Return an array of IDs of records in a given category.
- removefrom() : mixed
- Removes a record from a category.
- tableCat2main() : string
- Converts a category table (e.g. 'articles_cat_list') into a main table (e.g. 'articles') Assumes standard naming conventions.
- tableMain2cat() : string
- Converts a main table name into a category table name.
- tableMain2joiner() : string
- Converts a main table name into a joiner table name.
Methods
categoryList()
Return an array of IDs of categories a record is in.
public
static categoryList(string $table, int $record_id) : mixed
If there are no categories, returns an empty array.
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $record_id : int
-
The id in the main table.
columnMain2joiner()
Converts a main table name into a joiner column name.
public
static columnMain2joiner(string $table) : string
Assumes standard naming conventions.
Parameters
- $table : string
-
Main table name, e.g. 'articles'
Tags
Return values
string —Joiner column name, e.g. 'article_id'
contains()
Does a given category contatin a given record? Returns true if found, false otherwise
public
static contains(string $table, int $record_id, int $category_id) : mixed
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $record_id : int
-
The id in the main table.
- $category_id : int
-
The id in the category table.
create()
Creates a category.
public
static create(string $table, string $name) : mixed
Returns the id or NULL on failure.
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $name : string
-
The name of the category to add
insertInto()
Inserts a record into a category.
public
static insertInto(string $table, int $record_id, int $category_id) : bool
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $record_id : int
-
The id in the main table.
- $category_id : int
-
The id in the category table.
Return values
bool —True if adding the record to the category succeeded
lookup()
Looks up a category.
public
static lookup(string $table, string $name[, bool $case_sensitive = false ]) : mixed
Returns the id, or NULL if not found.
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $name : string
-
The name of the category to find
- $case_sensitive : bool = false
-
True for a case sensitive match. Default false
lookupOrCreate()
Looks up a category. If not found, creates the category.
public
static lookupOrCreate(string $table, string $name[, bool $case_sensitive = false ]) : mixed
Returns the id or NULL on failure.
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $name : string
-
The name of the category to find or add
- $case_sensitive : bool = false
-
True for a case sensitive match. Default false
name()
public
static name(string $table, int|string $id) : string|null
Parameters
- $table : string
- $id : int|string
Return values
string|nullrecordList()
Return an array of IDs of records in a given category.
public
static recordList(string $table, int $category_id) : mixed
If there are no records, returns an empty array.
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $category_id : int
-
The id in the category table.
removefrom()
Removes a record from a category.
public
static removefrom(string $table, int $record_id, int $category_id) : mixed
Returns true on success and false on failure
Parameters
- $table : string
-
The 'main' table (e.g. 'articles')
- $record_id : int
-
The id in the main table.
- $category_id : int
-
The id in the category table.
tableCat2main()
Converts a category table (e.g. 'articles_cat_list') into a main table (e.g. 'articles') Assumes standard naming conventions.
public
static tableCat2main(string $table) : string
Parameters
- $table : string
-
Category table name, e.g. 'articles_cat_list'
Tags
Return values
string —Main table name, e.g. 'articles'
tableMain2cat()
Converts a main table name into a category table name.
public
static tableMain2cat(string $table) : string
Assumes standard naming conventions.
Parameters
- $table : string
-
Main table name, e.g. 'articles'
Tags
Return values
string —Category table name, e.g. 'articles_cat_list'
tableMain2joiner()
Converts a main table name into a joiner table name.
public
static tableMain2joiner(string $table) : string
Assumes standard naming conventions.
Parameters
- $table : string
-
Main table name, e.g. 'articles'
Tags
Return values
string —Joiner table name, e.g. 'articles_cat_join'