Tuskfish API
  • Package
  • Class

Packages

  • content
  • core
  • database
  • installation
  • security
  • user
  • utilities

Classes

  • TfishCriteria
  • TfishCriteriaItem
  • TfishDatabase

Class TfishCriteria

Query composer class for SQLite database.

Use this class to set parameters on database-related actions. Individual conditions are held within the item property, as TfishCriteriaItem objects. Criteria holds the basic query parameters and controls how TfishCriteriaItem are chained together (eg. with "AND", "OR").

See the Tuskfish Developer Guide for a full explanation and examples.

Package: database
Copyright: Simon Wilkinson 2013-2017 (https://tuskfish.biz)
License: GNU General Public License (GPL) V2
Author: Simon Wilkinson simon@isengard.biz
Version: Release: 1.0
Since: 1.0
Located at trust_path/libraries/tuskfish/class/TfishCriteria.php

Methods summary

public
# add( TfishCriteriaItem $criteria_item, string $condition = "AND" )

Add conditions (TfishCriteriaItem) to a query.

Add conditions (TfishCriteriaItem) to a query.

Parameters

$criteria_item
TfishCriteriaItem object.
$condition
Condition used to chain TfishCriteriaItems, "AND" or "OR" only.
public mixed|null
# __get( string $property )

Get the value of a property.

Get the value of a property.

Intercepts direct calls to access an object property. This method can be modified to impose processing logic to the value before returning it.

Parameters

$property
Name of property.

Returns

mixed|null
$property Value of property if it is set; otherwise null.
public boolean
# __isset( string $property )

Check if a property is set.

Check if a property is set.

Intercepts isset() calls to correctly read object properties. Can be modified to add processing logic for specific properties.

Parameters

$property
Name of property.

Returns

boolean
True if set, otherwise false.
public
# killType( integer $key )

Unset existing type criteria.

Unset existing type criteria.

Used by content object handler subclasses to remove any existing type filter when they may need to set or reset it to a specific type.

Parameters

$key
Key of the item array containing the type filter.
public
# __set( string $property, mixed $value )

Set the value of a property and will not allow non-whitelisted properties to be set.

Set the value of a property and will not allow non-whitelisted properties to be set.

Intercepts direct calls to set the value of an object property. This method can be modified to impose data type restrictions and range checks before allowing the property to be set.

Parameters

$property
Name of property.
$value
Value of property.
public string
# renderSQL( )

Generate an SQL WHERE clause with PDO placeholders based on criteria items.

Generate an SQL WHERE clause with PDO placeholders based on criteria items.

Loop through the criteria items building a list of PDO placeholders together with the SQL. These will be used to bind the values in the statement to prevent SQL injection. Note that values are NOT inserted into the SQL directly.

Enclose column identifiers in backticks to escape them. Link criteria items with AND/OR except on the last iteration ($count-1).

Returns

string
$sql SQL query fragment.
public array
# renderPDO( )

Generate an array of PDO placeholders based on criteria items.

Generate an array of PDO placeholders based on criteria items.

Use this function to get a list of placeholders generated by renderSQL(). The two functions should be used together; use renderSQL() to create a WHERE clause with named placeholders, and renderPDO() to get a list of the named placeholders so that you can bind values to them.

Returns

array
$pdo_placeholders Array of PDO placeholders used for building SQL query.
public string
# renderTagSQL( )

Generate an SQL WHERE clause with PDO placeholders based on the tag property.

Generate an SQL WHERE clause with PDO placeholders based on the tag property.

Loop through the criteria->tags building a list of PDO placeholders together with the SQL. These will be used to bind the values in the statement to prevent SQL injection. Note that values are NOT inserted into the SQL directly.

Returns

string
$sql SQL query fragment.
public array
# renderTagPDO( )

Generate an array of PDO placeholders based on the tag property.

Generate an array of PDO placeholders based on the tag property.

Use this function to get a list of placeholders generated by renderTagSQL(). The two functions should be used together; use renderTagSQL() to create a WHERE clause with named placeholders, and renderTagPDO() to get a list of the named placeholders so that you can bind values to them.

Returns

array
$tag_placeholders Array of PDO placeholders used for building SQL query.
public boolean
# __unset( string $property )

Unsets a property.

Unsets a property.

Intercepts unset() calls to correctly unset object properties. Can be modified to add processing logic for specific properties.

Parameters

$property
Name of property.

Returns

boolean
True on success false on failure.

Properties summary

protected array $__data

$__data Holds the values of the object's properties for access by magic methods. *

$__data Holds the values of the object's properties for access by magic methods. *

# array( 'item' => array(), 'condition' => array(), 'groupby' => false, 'limit' => 0, 'offset' => 0, 'order' => false, 'ordertype' => "DESC", 'tag' => array() )

Magic properties

public array $item

Array of TfishCriteriaItem

public array $condition

Array of conditions used to join TfishCriteriaItem (AND, OR)

public string $groupby

Column to group results by

public integer $limit

Number of records to retrieve

public integer $offset

Starting point for retrieving records

public string $order

Sort order

public string $ordertype

Sort ascending (ASC) or descending(DESC)

public array $tag

Array of tag IDs

Tuskfish API API documentation generated by ApiGen