Class vB_DataManager_Multiple

Description

Abstract class to do data update operations for a particular data type (such as user, thread, post etc.).

Works on multiple records simultaneously. Updates will occur on all records matching set_condition().

  • version: $Revision: 33877 $
  • date: $Date: 2009-11-27 11:25:30 -0600 (Fri, 27 Nov 2009) $

Located in /includes/class_dm.php (line 1620)


	
			
Direct descendents
Class Description
 class vB_DataManager_ThreadRate_Multiple Class to do data update operations for multiple THREADRATE simultaneously
 class vB_DataManager_Post_Multiple Class to do data update operations for multiple POSTS simultaneously
 class vB_DataManager_Thread_Multiple Class to do data update operations for multiple THREADS simultaneously
 class vB_DataManager_User_Multiple Class to do data update operations for multiple USERS simultaneously
Variable Summary
Method Summary
 vB_DataManager_Multiple vB_DataManager_Multiple (vB_Registry &$registry, [integer $errtype = ERRTYPE_STANDARD])
 void add_existing (array &$existing)
 void batch_iterate (string|resource $records, callback $callback, [integer $batch_size = 500], [array $args = array()])
 void copy_changes ()
 void execute_query ([boolean $doquery = true])
 mixed &fetch_field (string $fieldname, [string $table = null])
 string fetch_query ([string $condition = ''], [integer $limit = 0], [integer $offset = 0])
 void reset ()
 boolean save ([boolean $doquery = true], [boolean $call_save_once = true])
 boolean set (string $fieldname, mixed $value, [boolean $clean = true], [boolean $doverify = true], string 4)
 boolean set_bitfield (string $fieldname, string $bitname, boolean $onoff)
 integer set_condition ([string $condition = ''], [integer $limit = 0], [integer $offset = 0])
 void set_info (string $fieldname, mixed $value)
Variables
vB_DataManager $base_object = null (line 1657)

The base object of type $class_name. This is created in the constructor for optimization purposes. Do not change this object.

array $children = array() (line 1675)

Holds an array of vB_DataManager objects that matched the condition specified in a call to set_condition(). The first object in this array becomes the "master".

Changes are done to it first; changes are not pushed to the rest of the matches until copy_changes() is called.

  • var: Key: Primary ID of record; value: vB_DataManager object
string $class_name = 'vB_DataManager' (line 1649)

The name of the class to instantiate for each matching. It is assumed to exist! It should be a subclass of vB_DataManager.


Redefined in descendants as:
vB_Database $dbobject = null (line 1634)

The vBulletin database object

integer $error_handler = ERRTYPE_STANDARD (line 1641)

The error handler for the child objects. Should be one of the ERRTYPE_* constants.

string $primary_id = 'dataid' (line 1665)

The name of the primary ID column that is used to uniquely identify records retrieved.

This will be used to build the condition in all update queries!


Redefined in descendants as:
array $primary_ids = array() (line 1684)

Array of the primary ID fields (as specified by $primary_id) of any records that matched in a call to set_condition(). This is used to build the condition when saving.

vB_Registry $registry = null (line 1627)

The vBulletin registry object

Methods
Constructor vB_DataManager_Multiple (line 1692)

Constructor - checks that the registry object has been passed correctly.

vB_DataManager_Multiple vB_DataManager_Multiple (vB_Registry &$registry, [integer $errtype = ERRTYPE_STANDARD])
  • vB_Registry &$registry: Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  • integer $errtype: One of the ERRTYPE_x constants
add_existing (line 1758)

This function adds an existing record to the data manager. This is helpful if you have already executed the query to grab the data, for example.

void add_existing (array &$existing)
  • array &$existing: Array of existing data. MUST HAVE THE PRIMARY ID!
batch_iterate (line 1992)

This function iterate over a large result set, only processing records in

batches to keep the memory usage reasonable. After a batch has been collected, a reference to this object is passed to a callback function. That function will update any columns necessary. This function will the save the changes and start on a new batch.

Callback function first argument must be a reference to a vB_DataManager_Multiple object. Additional arguments should be passed to this function in an array.

void batch_iterate (string|resource $records, callback $callback, [integer $batch_size = 500], [array $args = array()])
  • string|resource $records: A query result resource or a string containing the query to execute
  • callback $callback: The function to call to make changes to the records
  • integer $batch_size: Number of records to process in a batch
  • array $args: Any additional arguments to pass to the callback function
copy_changes (line 1880)

Pushes the changes made to the "master" child to the rest.

void copy_changes ()

Redefined in descendants as:
execute_query (line 1948)

Executes the necessary query/queries to update the records

void execute_query ([boolean $doquery = true])
  • boolean $doquery: Actually perform the query?

Redefined in descendants as:
fetch_field (line 1795)

Allows you to fetch the value of a field whose value was changed.

This does not look at existing data as it may vary from record to record!

  • return: The requested data
mixed &fetch_field (string $fieldname, [string $table = null])
  • string $fieldname: Field name
  • string $table: Table name to force. Leave as null to use the default table
fetch_query (line 1781)

Builds the SQL to run to fetch records. This must be overridden by a child class!

  • return: The query to execute
string fetch_query ([string $condition = ''], [integer $limit = 0], [integer $offset = 0])
  • string $condition: Condition to use in the fetch query; the entire WHERE clause
  • integer $limit: The number of records to limit the results to; 0 is unlimited
  • integer $offset: The number of records to skip before retrieving matches.

Redefined in descendants as:
reset (line 1971)

Removes the records stored in the manager, resetting it (essentially) to its start state.

void reset ()
save (line 1905)

Saves the data from the object into the specified database tables

  • return: True on success; false on failure
boolean save ([boolean $doquery = true], [boolean $call_save_once = true])
  • boolean $doquery: Do the query?
  • boolean $call_save_once: Whether to call post_save_once() at the end
set (line 1831)

Sets the supplied data to be part of the data to be saved

  • return: Returns false if the data is rejected for whatever reason
boolean set (string $fieldname, mixed $value, [boolean $clean = true], [boolean $doverify = true], string 4)
  • string 4: Table name to force. Leave as null to use the default table
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed $value: The data itself
  • boolean $clean: Clean data, or insert it RAW (used for non-arbitrary updates, like posts = posts + 1)
  • boolean $doverify: Whether to verify the data with the appropriate function. Still cleans data if previous arg is true.
set_bitfield (line 1851)

Sets a bit in a bitfield

boolean set_bitfield (string $fieldname, string $bitname, boolean $onoff)
  • string $fieldname: Name of the database bitfield (options, permissions etc.)
  • string $bitname: Name of the bit within the bitfield (canview, canpost etc.)
  • boolean $onoff: Whether the bit should be set or not
set_condition (line 1733)

Queries for matching records based on the condition specified, and sets up the manager to make modifications to those records.

  • return: The number of matching records
integer set_condition ([string $condition = ''], [integer $limit = 0], [integer $offset = 0])
  • string $condition: Condition to use in the fetch query; the entire WHERE clause
  • integer $limit: The number of records to limit the results to; 0 is unlimited
  • integer $offset: The number of records to skip before retrieving matches.
set_info (line 1868)

Rather like set(), but sets data into the $this->info array instead

void set_info (string $fieldname, mixed $value)
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed $value: The data itself

Documentation generated on Tue, 26 Jan 2010 15:15:09 -0600 by phpDocumentor 1.4.3