PHP Class PodsData, pods

Afficher le fichier Open project: pods-framework/pods Class Usage Examples

Méthodes publiques

Свойство Type Description
$aliases array
$api PodsAPI
$data
$detail_page
$display_errors boolean
$field_id string
$field_index string
$field_slug string
$fields array
$filters array
$id integer
$insert_id
$instance PodsData
$join string
$limit integer
$orderby string
$page integer
$page_var string
$pagination boolean
$pod null
$pod_data array | boolean | mixed | null | void
$row
$row_number integer
$search boolean
$search_fields array
$search_mode string
$search_query string
$search_var string
$search_where string
$select null
$sql string Last select() query SQL
$table null
$total
$total_found
$total_found_calculated boolean
$total_sql string Last total sql
$traversal array Holds Traversal information about Pods
$traverse array Holds custom Traversals to be included
$where array
$where_default array

Protected Properties

Свойство Type Description
$field_types array
$prefix string

Méthodes publiques

Méthode Description
__construct ( string $pod = null, integer $id, boolean $strict = true ) : PodsData Data Abstraction Class for Pods
build ( array $params ) : boolean | mixed | string Build/Rewrite dynamic SQL and handle search/filter/sort
calculate_totals ( )
delete ( string $table, array $where, array $where_format = null ) : array | boolean | mixed | null | void Delete an item
fetch ( integer $row = null, boolean $explicit_set = true ) : mixed Fetch a new row for the current pod_data
get_column_data ( string $column_name, string $table ) : array Gets column data information from a table
get_sql ( $sql ) Get the complete sql
get_table_columns ( string $table ) : array Gets column information from a table
get_tables ( boolean $wp_core = true, boolean $pods_tables = true ) : array Gets all tables in the WP database, optionally exclude WP core tables, and/or Pods table by settings the parameters to false.
init ( string $pod = null, integer $id, boolean $strict = true ) : PodsData Singleton handling for a basic pods_data() request
insert ( string $table, array $data, array $format = null ) : integer | boolean Insert an item, eventually mapping to WPDB::insert
insert_on_duplicate ( string $table, array $data, array $formats = [] ) : mixed
nth ( integer | string $nth ) : boolean Fetch the nth state
position ( ) : integer Fetch the current position in the loop (starting at 1)
prepare ( string $sql, array $data ) : boolean | null | string Prepare values for the DB
query ( string | array $sql, string $error = 'Database Error', null $results_error = null, null $no_results_error = null ) : array | boolean | mixed | null | void
query_field ( string | integer $field, array | string $q, array $pod = null, object &$params = null ) : string | null Get the string to use in a query for matching, uses WP_Query meta_query arguments
query_fields ( array $fields, array $pod = null, object &$params = null ) : string | null Get the string to use in a query for WHERE/HAVING, uses WP_Query meta_query arguments
reorder ( string $table, string $weight_field, string $id_field, array $ids ) : boolean Reorder Items
reset ( integer $row = null ) : mixed Reset the current data
select ( array $params ) : array | boolean | mixed Select items, eventually building dynamic query
table ( array | string $table, string $object = '' ) Handle tables like they are Pods (for traversal in select/build)
table_alter ( string $table, string $changes ) : array | boolean | mixed | null | void Alter a Table
table_create ( string $table, string $fields, boolean $if_not_exists = false ) : array | boolean | mixed | null | void Create a Table
table_drop ( string $table ) : array | boolean | mixed | null | void Drop a Table
table_truncate ( string $table ) : array | boolean | mixed | null | void Truncate a Table
total ( ) : integer Fetch the total row count returned
total_found ( ) : integer Fetch the total row count total
traverse ( array $fields = null, null $all_fields = null, object $params = null ) : array Recursively join tables based on fields
traverse_build ( array $fields = null, object $params = null ) : array Setup fields for traversal
traverse_recurse ( array $traverse_recurse ) : array Recursively join tables based on fields
update ( string $table, array $data, array $where, array $format = null, array $where_format = null ) : boolean Update an item, eventually mapping to WPDB::update
zebra ( ) : boolean Fetch the zebra state

Private Methods

Méthode Description
do_hook ( ) Handle filters / actions for the class

Method Details

__construct() public méthode

Data Abstraction Class for Pods
Since: 2.0
public __construct ( string $pod = null, integer $id, boolean $strict = true ) : PodsData
$pod string Pod name
$id integer Pod Item ID
$strict boolean If true throws an error if a pod is not found.
Résultat PodsData

build() public méthode

Build/Rewrite dynamic SQL and handle search/filter/sort
Since: 2.0
public build ( array $params ) : boolean | mixed | string
$params array
Résultat boolean | mixed | string

calculate_totals() public méthode

public calculate_totals ( )

delete() public méthode

Delete an item
Since: 2.0
public delete ( string $table, array $where, array $where_format = null ) : array | boolean | mixed | null | void
$table string Table name
$where array A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw".
$where_format array (optional) An array of formats to be mapped to each of the values in $where.
Résultat array | boolean | mixed | null | void

fetch() public méthode

Fetch a new row for the current pod_data
Since: 2.0
public fetch ( integer $row = null, boolean $explicit_set = true ) : mixed
$row integer Row number to fetch
$explicit_set boolean Whether to set explicitly (use false when in loop)
Résultat mixed

get_column_data() public static méthode

Gets column data information from a table
Since: 2.0
public static get_column_data ( string $column_name, string $table ) : array
$column_name string Column name
$table string Table name
Résultat array

get_sql() public méthode

Get the complete sql
Since: 2.0.5
public get_sql ( $sql )

get_table_columns() public static méthode

Gets column information from a table
Since: 2.0
public static get_table_columns ( string $table ) : array
$table string Table Name
Résultat array

get_tables() public static méthode

Gets all tables in the WP database, optionally exclude WP core tables, and/or Pods table by settings the parameters to false.
Since: 2.0
public static get_tables ( boolean $wp_core = true, boolean $pods_tables = true ) : array
$wp_core boolean
$pods_tables boolean restrict Pods 2.x tables
Résultat array

init() public static méthode

Singleton handling for a basic pods_data() request
Since: 2.3.5
public static init ( string $pod = null, integer $id, boolean $strict = true ) : PodsData
$pod string Pod name
$id integer Pod Item ID
$strict boolean If true throws an error if a pod is not found.
Résultat PodsData

insert() public méthode

Insert an item, eventually mapping to WPDB::insert
Since: 2.0
public insert ( string $table, array $data, array $format = null ) : integer | boolean
$table string Table name
$data array Data to insert (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
$format array (optional) An array of formats to be mapped to each of the value in $data.
Résultat integer | boolean The ID of the item

insert_on_duplicate() public static méthode

Since: 2.0
public static insert_on_duplicate ( string $table, array $data, array $formats = [] ) : mixed
$table string Name of the table to update
$data array column => value pairs
$formats array For $wpdb->prepare, uses sprintf formatting
Résultat mixed Sanitized query string

nth() public méthode

Fetch the nth state
Since: 2.3
public nth ( integer | string $nth ) : boolean
$nth integer | string The $nth to match on the PodsData::row_number
Résultat boolean Whether $nth matches

position() public méthode

Fetch the current position in the loop (starting at 1)
Since: 2.3
public position ( ) : integer
Résultat integer Current row number (+1)

prepare() public static méthode

Prepare values for the DB
Since: 2.0
public static prepare ( string $sql, array $data ) : boolean | null | string
$sql string SQL to prepare
$data array Data to add to the sql prepare statement
Résultat boolean | null | string

query() public static méthode

Since: 2.0
public static query ( string | array $sql, string $error = 'Database Error', null $results_error = null, null $no_results_error = null ) : array | boolean | mixed | null | void
$sql string | array The SQL to execute
$error string Error to throw on problems
$results_error null (optional)
$no_results_error null (optional)
Résultat array | boolean | mixed | null | void Result of the query

query_field() public static méthode

Get the string to use in a query for matching, uses WP_Query meta_query arguments
See also: PodsData::query_fields
Since: 2.3
public static query_field ( string | integer $field, array | string $q, array $pod = null, object &$params = null ) : string | null
$field string | integer Field name or array index
$q array | string Query array (meta_query) or string for matching
$pod array Related Pod
$params object Parameters passed from select()
Résultat string | null Query field string

query_fields() public static méthode

Get the string to use in a query for WHERE/HAVING, uses WP_Query meta_query arguments
Since: 2.3
public static query_fields ( array $fields, array $pod = null, object &$params = null ) : string | null
$fields array Array of field matches for querying
$pod array Related Pod
$params object Parameters passed from select()
Résultat string | null Query string for WHERE/HAVING

reorder() public méthode

Reorder Items
Since: 2.0
public reorder ( string $table, string $weight_field, string $id_field, array $ids ) : boolean
$table string Table name
$weight_field string
$id_field string
$ids array
Résultat boolean

reset() public méthode

Reset the current data
Since: 2.0
public reset ( integer $row = null ) : mixed
$row integer Row number to reset to
Résultat mixed

select() public méthode

Select items, eventually building dynamic query
Since: 2.0
public select ( array $params ) : array | boolean | mixed
$params array
Résultat array | boolean | mixed

table() public méthode

Handle tables like they are Pods (for traversal in select/build)
public table ( array | string $table, string $object = '' )
$table array | string
$object string

table_alter() public static méthode

Alter a Table
Since: 2.0
public static table_alter ( string $table, string $changes ) : array | boolean | mixed | null | void
$table string Table name
$changes string
Résultat array | boolean | mixed | null | void

table_create() public static méthode

Create a Table
Since: 2.0
public static table_create ( string $table, string $fields, boolean $if_not_exists = false ) : array | boolean | mixed | null | void
$table string Table name
$fields string
$if_not_exists boolean Check if the table exists.
Résultat array | boolean | mixed | null | void

table_drop() public static méthode

Drop a Table
Since: 2.0
public static table_drop ( string $table ) : array | boolean | mixed | null | void
$table string Table name
Résultat array | boolean | mixed | null | void

table_truncate() public static méthode

Truncate a Table
Since: 2.0
public static table_truncate ( string $table ) : array | boolean | mixed | null | void
$table string Table name
Résultat array | boolean | mixed | null | void

total() public méthode

Fetch the total row count returned
Since: 2.0
public total ( ) : integer
Résultat integer Number of rows returned by select()

total_found() public méthode

Fetch the total row count total
Since: 2.0
public total_found ( ) : integer
Résultat integer Number of rows found by select()

traverse() public méthode

Recursively join tables based on fields
public traverse ( array $fields = null, null $all_fields = null, object $params = null ) : array
$fields array Fields to recurse
$all_fields null (optional) If $fields is empty then traverse all fields, argument does not need to be passed
$params object (optional) Parameters from build()
Résultat array Array of joins

traverse_build() public méthode

Setup fields for traversal
Since: 2.0
public traverse_build ( array $fields = null, object $params = null ) : array
$fields array Associative array of fields data
$params object (optional) Parameters from build()
Résultat array Traverse feed

traverse_recurse() public méthode

Recursively join tables based on fields
Since: 2.0
public traverse_recurse ( array $traverse_recurse ) : array
$traverse_recurse array Array of traversal options
Résultat array Array of table joins

update() public méthode

Update an item, eventually mapping to WPDB::update
Since: 2.0
public update ( string $table, array $data, array $where, array $format = null, array $where_format = null ) : boolean
$table string Table name
$data array Data to update (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
$where array A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw".
$format array (optional) An array of formats to be mapped to each of the values in $data.
$where_format array (optional) An array of formats to be mapped to each of the values in $where.
Résultat boolean

zebra() public méthode

Fetch the zebra state
See also: PodsData::nth
Since: 1.12
public zebra ( ) : boolean
Résultat boolean Zebra state

Property Details

$aliases public_oe property

public array $aliases
Résultat array

$api public_oe property

public PodsAPI $api
Résultat PodsAPI

$data public_oe property

public $data

$detail_page public_oe property

public $detail_page

$display_errors public_oe static_oe property

public static bool $display_errors
Résultat boolean

$field_id public_oe property

public string $field_id
Résultat string

$field_index public_oe property

public string $field_index
Résultat string

$field_slug public_oe property

public string $field_slug
Résultat string

$field_types protected_oe static_oe property

protected static array $field_types
Résultat array

$fields public_oe property

public array $fields
Résultat array

$filters public_oe property

public array $filters
Résultat array

$id public_oe property

public int $id
Résultat integer

$insert_id public_oe property

public $insert_id

$instance static_oe public_oe property

static public PodsData $instance
Résultat PodsData

$join public_oe property

public string $join
Résultat string

$limit public_oe property

public int $limit
Résultat integer

$orderby public_oe property

public string $orderby
Résultat string

$page public_oe property

public int $page
Résultat integer

$page_var public_oe property

public string $page_var
Résultat string

$pagination public_oe property

public bool $pagination
Résultat boolean

$pod public_oe property

public null $pod
Résultat null

$pod_data public_oe property

public array|bool|mixed|null|void $pod_data
Résultat array | boolean | mixed | null | void

$prefix protected_oe static_oe property

protected static string $prefix
Résultat string

$row public_oe property

public $row

$row_number public_oe property

public int $row_number
Résultat integer

$search_fields public_oe property

public array $search_fields
Résultat array

$search_mode public_oe property

public string $search_mode
Résultat string

$search_query public_oe property

public string $search_query
Résultat string

$search_var public_oe property

public string $search_var
Résultat string

$search_where public_oe property

public string $search_where
Résultat string

$select public_oe property

public null $select
Résultat null

$sql public_oe property

Last select() query SQL
public string $sql
Résultat string

$table public_oe property

public null $table
Résultat null

$total public_oe property

public $total

$total_found public_oe property

public $total_found

$total_found_calculated public_oe property

public bool $total_found_calculated
Résultat boolean

$total_sql public_oe property

Last total sql
public string $total_sql
Résultat string

$traversal public_oe property

Holds Traversal information about Pods
public array $traversal
Résultat array

$traverse public_oe property

Holds custom Traversals to be included
public array $traverse
Résultat array

$where public_oe property

public array $where
Résultat array

$where_default public_oe property

public array $where_default
Résultat array