Packageindex Classtrees Modulegroups Elementlist Report XML Files

pxdb.content.output

pxdb_collection

pxdb_data
   |
  +-- pxdb_collection

public class pxdb_collection extends pxdb_data

This class includes some methods that are just wrappers for ADOdb methods -- e.g. execute_page() is essentially a wrapper for PageExecute(). This will, however, provide needed flexibility for extending the functionality of these ADOdb methods and for exchanging ADOdb with another solution (PEAR) should it become necessary.

AuthorsHans Lellelid <hans@velum.net>
Version$Revision: 1.14 $

 

Methods inherited from pxdb_data

pxdb_data, get_datatype, get_datatype_list, get_datatype_array, set_datatype, bind_tpl, bind_auth, lookup_colname, lookup_tfid, get_column_identifiers, get_identifiers, set_user_minimal_columns, sql_minimal_columns, sql_aliased_columns

Public Method Summary

void pxdb_collection([ mixed $dt ])

string get_sql()
Get the current class SQL statement.
boolean is_authorized(integer $record_id, [ string $priv ])
Checks to see if bound auth object is authorized to access (default = 'read') this record.
object The &fetch_record([ string $classname ])
Gets the next record in result set ($rs).
string &find([ mixed $data ])
Executes passed SQL or SQL derived from passed pxdb_search object.
boolean &execute()
Wrapper for ADOdb Execute
mixed &execute_limit([ integer $limit, integer $offset ])
Wrapper for ADOdb SelectLimit.
mixed &raw_execute_page(integer $nrows, integer $page)
Wrapper for ADOdb ExecutePage
mixed &execute_page(integer $nrows, integer $page)
Rewrite ExecutePage to use a limit and avoid the performance penalty of
integer num_records()
Wrapper for ADOdb recordset RecordCount().
integer total_num_records()
Get total number of records (if using paged queries).
void weighted_childtype(integer $relid)
EXPERIMENTAL, UNIMPLEMENTED Specifies that the result set is a weighted child-datatype list.
void set_order_strict(mixed $orderby)
Sets the order without doing any checking on column type, etc.
void set_order(mixed $orderby, [ array $join_cols ])
Sets the order for the "ORDER BY" clause.
mixed get_order()
Returns the current order set for the collection
boolean set_show_unapproved(boolean $set)
Sets show_unapproved, whether results that haven't been approved should be returned.Warning: documentation is missing.
string priv_filter_sql(string $sql)
Filters a SQL statement to only return entries that current user has read privs for.
void set_priv_ugids(array $ugids)
Explicitly sets the user and group ids to use when filtering privs
string build_sql(object [unknown] $search)
Builds a SQL statement based on a filter.
void findCount( $search)
Prepares sql for getting a count of matching rows for a collection.
integer fetchCount( $search)
Conveniece method - returns the total number of records in the collection using mysql count() function for speed.

Private Method Summary

string _get_datatype_where()
Returns the clause needed in collection's sql to restrict by datatype. For
string _object_sql()
Builds the default SQL for getting records for this datatype.
string _minimal_sql()
Build minimal SQL.
string _get_oby_join_sql(string $records_alias)
Builds SQL for JOINS that support the ORDER BY clause
string _get_oby_sql(string $records_alias)
Get SQL for ORDER BY statement.
void use_public_privs([ boolean $set ])
Sets the collection to enforce public privs if no user is bound to it
string _get_priv_sql(string $records_alias)
Gets the JOIN SQL to restrict by authenticated privs.
void _count_sql( $search)
Faster function for getting the total number of records in a collection (see also total_num_records)

Fields inherited from pxdb_data

$debug, $errors, $datatype, $auth, $tpl, $show_unapproved, $db, $user_minimal_columns

Public Field Summary

$rs
The record set of current fetch.
$sql
The SQL that generated the current record set.
boolean $priv_filtered
Whether data has been filtered by user privileges.

Private Field Summary

array $orderby
Stores order by for SQL.
array $pick_joins
Used for order by on pickid columns.
array $weight_joins
Used for order by on weight table.
unknown $_public_privs
Boolean used to locally override global priv filtering
$_priv_ugids
Can set the group/user ids to priv filter for here
boolean $_find_called
Tracks if find method has been called before execute
unknown $this

Public Method Details

pxdb_collection

public void pxdb_collection([ mixed $dt ])

 

Parameter
mixed $dt = >>null<<
Current datatype(s): Array, list, integer.
Returns void


get_sql

public string get_sql()

  This is useful if you want to you your own DB accessing tools to fetch content or if you want to further filter the SQL produced by a collection. (this allows you to get around issues of needing to combine search-type and filter-type pxdb_search classes.

Returns string

The class SQL statement.


is_authorized

public boolean is_authorized(integer $record_id, [ string $priv ])

 

Parameter
integer $record_id
the ID of the record we are checking.
string $priv = >>'read'<<
The priv we are looking for.
Returns boolean


&fetch_record

public object The &fetch_record([ string $classname ])

 

Parameter
string $classname = >>null<<
The name of the class to return as a record. (default is pxdb_record)
Returns object The

next record in result set.


&find

public string &find([ mixed $data ])

  If SQL is passed just sets the class var so that calls to find_record() will be able to execute the query.

Parameter
mixed $data = >>null<<
The SQL statement or object search on.
Returns string

The SQL that will be used in the query.


&execute

public boolean &execute()

 

Returns boolean

Status of query execution


&execute_limit

public mixed &execute_limit([ integer $limit, integer $offset ])

  Sets the class $rs attribute.

Parameter
integer $limit = >>-1<<
integer $offset = >>-1<<
Returns mixed

ADOdb result set or false on error.


&raw_execute_page

public mixed &raw_execute_page(integer $nrows, integer $page)

 

Parameter
integer $nrows
The number of rows per page.
integer $page
The page to show.
Returns mixed

ADOdb result set or false on error.


&execute_page

public mixed &execute_page(integer $nrows, integer $page)

  using the same query twice.

Parameter
integer $nrows
The number of rows per page.
integer $page
The page to show.
Returns mixed

ADOdb result set or false on error.


num_records

public integer num_records()

  Note that if you are doing a paged-query (execute_page()) this will only return the number of records on current page (current recordset). To find the total number of records use the total_num_records() method.

Returns integer

Number of records in current recordset.

Since 0.0.2

total_num_records

public integer total_num_records()

  Currently ADOdb does not have good support for getting total number of records when using PageExecute().

Returns integer

Total number of records found.

Since 0.0.2

weighted_childtype

public void weighted_childtype(integer $relid)

  Child datatypes are datatypes that have specified parent relids (a relationship relating child datatype to the parent datatype(s)). It is assumed that if you specify that this result set is a weighted_childtype, that you have also applied a filter restricting the results to the children of one particular record. If you don't restrict your results, then the order/placement of results will be incorrect. EXPERIMENTAL, UNIMPLIMENTED

Parameter
integer $relid
The RELID relating the children
Returns void


set_order_strict

public void set_order_strict(mixed $orderby)

 

Parameter
mixed $orderby
ORDER BY string or array of strings
Returns void


set_order

public void set_order(mixed $orderby, [ array $join_cols ])

  Designed to be used if this class is building your whole SQL statement for you. Setting order can actually be a complex task, since any lookups on pickids are performed -- and tables joined (LEFT) if necessary.

Parameter
mixed $orderby
ORDER BY string or array of strings.
array $join_cols = >>null<<
Hash of [field names] => [related col to orderby]
Returns void


get_order

public mixed get_order()

 

Returns mixed

, returns false if no order is set

Author(s)

set_show_unapproved

public boolean set_show_unapproved(boolean $set)

 

Warning: documentation is missing.

Parameter
boolean $set
Returns boolean

True or false on error


priv_filter_sql

public string priv_filter_sql(string $sql)

  Works by inserting an INNER JOIN in the FROM clause (actually, before the WHERE clause) of the passed SQL.

Parameter
string $sql
The SQL statement to filter.
Returns string $sql

The filtered SQL statement.


set_priv_ugids

public void set_priv_ugids(array $ugids)

  By default, if a logged in user is detected it will use all their groups, otherwise the collection should restrict to the Everyone(0) group

Parameter
array $ugids
string comma-seperated list of user/group ids
Returns void


build_sql

public string build_sql(object [unknown] $search)

  This method builds a complete SQL statement -- including privilege filtering and approval filtering based on values in the passed filter.

Parameter
object [unknown] $search
A pxdb_search object for which to build SQL.
Returns string

The SQL statement.


findCount

public void findCount( $search)

  Should really use fetchCount method.

Parameter
$search
Warning: documentation is missing.
Returns void


fetchCount

public integer fetchCount( $search)

  instead of total_num_records

Parameter
$search
Warning: documentation is missing.
Returns integer


Private Method Details

_get_datatype_where

private string _get_datatype_where()

  single datatype uses =, multiple uses IN()

Returns string


_object_sql

private string _object_sql()

  Duplicates some functionality of build_sql() but is designed to be.

Returns string

The SQL for this datatype


_minimal_sql

private string _minimal_sql()

  This is for cases when pxdb_collection is being used for multiple (or no) datatypes. In these cases it doesn't make sense to fetch the aliased columns list, etc. -- so a very minimal SQL statement is built.

Returns string

The SQL

Since 0.0.3

_get_oby_join_sql

private string _get_oby_join_sql(string $records_alias)

 

Parameter
string $records_alias
The alias to the records table
Returns string

SQL for JOINS related to ORDER BY clause


_get_oby_sql

private string _get_oby_sql(string $records_alias)

 

Parameter
string $records_alias
The alias to the records table
Returns string

SQL for ORDER BY statemetn


use_public_privs

private void use_public_privs([ boolean $set ])

  Defaults to false, use this method to turn it on.

Parameter
boolean $set = >>true<<
Returns void


_get_priv_sql

private string _get_priv_sql(string $records_alias)

 

Parameter
string $records_alias
The alias to the records table
Returns string

SQL


_count_sql

private void _count_sql( $search)

  Instead of getting the resultset and then counting the number of records, we ask mysql to do the heavy lifting. @private Added by oscar merida

Parameter
$search
Warning: documentation is missing.
Returns void


Public Field Details

$rs

public $rs

>>null<<


$sql

public $sql

>>null<<


$priv_filtered

public boolean $priv_filtered

>>false<<


Private Field Details

$orderby

private array $orderby

>><<


$pick_joins

private array $pick_joins

>><<


$weight_joins

private array $weight_joins

>><<


$_public_privs

private unknown $_public_privs

>><<


$_priv_ugids

private $_priv_ugids

>>null<<


$_find_called

private boolean $_find_called

>>false<<


$this

private unknown $this

>><<



Packageindex Classtrees Modulegroups Elementlist Report XML Files
Generated on Fri, 28 Apr 2006 19:07:22 -0400 by PHPDoc v1.5 www.phpdoc.de