RecordSet::getInformation - jcobban/Genealogy GitHub Wiki
$recordSet->getInformation()
Up: class RecordSet
This method returns information about the set, including information about the database table associated with this instance of RecordSet.
It returns an associative array of named characteristics:
key | description |
---|---|
'table' | SQL internal table name used in SQL commands. |
'name' | The external name of the table to be shown to users. |
'prime' | The primary key name for the table. The key name is in lower case so it will match the field name in the query response. If multiple fields are required to uniquely identify a record then this is an array of field names. |
'srvmg' | true if the setting of the primary key is managed by the database server for new records, and false if it is managed by the application. |
'fldcount' | Not currently used. This is a number which is greater than or equal to the number of fields in the unique record identifier, and less than or equal to the number of fields in the record. |
'order' | Default value of the ORDER BY clause for SELECT operations on this table. This is usually obtained from the $classname::$defaultOrder member of the associated class. If that is not defined then this is the same as 'prime'. This may be an empty string, in which case no ORDER BY clause is included in SELECT operations. Note that the ORDER BY clause for UPDATE operations is specified in the update method. |
'classname' | Name of the class that implements the interface to this table. |
'initrow' | Default initial row. This provides information on names, default values, and types of the fields in the table. This is usually obtained from the $classname::$initRow member of the associated class. If the class does not define that static member then the very first record is read from the table to obtain the definition. |
'query' | The SQL SELECT statement that is issued to obtain the subset of the records in the table that this instance can iterate over. This string includes the ORDER BY, OFFSET, and LIMIT clauses as well as the WHERE clause. Note that this value is a simulated command with parameter values in the string, not the actual command which is a prepared statement with insertion points. Also note that this string must be escaped if it is appended to $warn or otherwise written as part of a web page so that special characters used in SQL expressions, such as the less-than sign, will be displayed properly and not interpreted as HTML. |
'count' | The number of records in the record set identified by the WHERE clause. Note that this is the number of records that would be returned if there were no LIMIT clause in the request. |
'maxsetsize' | The maximum number of records which can be read into memory from the server. |
An Example:
$mainparms = array('limit' => 20,
'offset' => 0);
$users = new RecordSet('Users', $mainParms);
$readonly = $users->count() > 10;
$info = $users->getInformation();
$count = $info['count'];
In this case the contents of the response from getInformation is:
key | contents |
---|---|
prime | id |
srvmg | 1 |
fldcount | 7 |
classname | User |
table | Users |
name | Users |
order | UserName |
initrow | Array ( [username] => '' [password] => '' [shapassword] => '' [email] => '' [auth] => 'pending' [id] => 0 [options] => 1 ) |
maxsetsize | 1000 |
query | SELECT * FROM Users ORDER BY UserName LIMIT 20 |
count | 177 |
Note that $info['count']
is 177, the total number of entries in the table, and $user->count()
is 20, the number of entries actually in the set as restricted by the limit value.
Next: $recordset->count()