Record::getInformation - jcobban/Genealogy GitHub Wiki
Record::getInformation($tableName)
Up: class Record
This static method returns information about the database table explicitly identified by the parameter.
parameter | description |
---|---|
$tableName | A string identifying the table. This can either be the actual SQL table name or a synonym defined in Record::$externalTableNames. |
If there is an entry for $tableName
in Record::$externalTableNames
then it is translated to the internal table name. If there is an entry for the internal table name in Record::$primeKey
the response is obtained from that table. Otherwise $tableName
is assumed to be an English plural and the class name is the corresponding singular form. For example the following transformations are made:
$tableName
ending in '....ies' implies a class name ending in '...y'. For example a table 'Counties' is implemented by class 'Genealogy\County'. Otherwise ...$tableName
ending in '....sses' implies a class name ending in '...ss'. For example a table 'Addresses' is implemented by class 'Genealogy\Address'. Otherwise ...$tableName
ending in '....ses', where the 4th last character is not 's', implies a class name ending in '...se'. For example a table 'PictureBases' is implemented by class 'Genealogy\PictureBase'. Otherwise ...$tableName
ending in '....ren' implies a class name with the 'ren' omitted. For example a table 'Children' is implemented by class 'Genealogy\Child'. Otherwise ...$tableName
ending in '....s' implies a class name with the 's' omitted. For example a table 'Blogs' is implemented by class 'Genealogy\Blog'. Otherwise ...- the class name is assumed to be 'Genealogy\$tableName'.
This is the standard method to verify that a supplied table name is valid.
This returns an associative array of named characteristics or null
if the method was unable to load the class implementation.
name | contents |
---|---|
'table' | Internal table name to be 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 the table has multiple keys, this field 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. For example it is true for a MySQL table using an auto-increment key. |
'fldcount' | Not currently used. This is a number which is greater than or equal to the number of fields in the primary key, 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 as implemented by class RecordSet. This value 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. |
'classname' | Name of the class that implements the interface to this table. If there is no specific class then this contains 'Record'. This does not include the namespace qualifier. For example it contains 'Birth', not 'Genealogy\Birth'. |
'initrow' | Default initial row as an associative array. This provides information on names, default values, and types of the fields in the table. If this method is called for a table represented by a class, for example by calling Record::getInformation('Persons') the response contains the contents of the class specific value of the static attribute $initRow, in this example of Person::$initRow , otherwise it will contain a copy of the first row in the actual table. |
Note that the following return similar results:
$info = Record::getInformation('Surnames');
and
$surnames = new RecordSet('Surnames');
$info = $surnames->getInformation();
except that the second is more expensive, because it accesses the database server, and provides additional information including the total number of records in the table, since that form of the class RecordSet
constructor creates an instance which represents all of the records in the table. The constructor also throws an exception if the table name is unsupported where Record::getInformation
returns null. See class RecordSet.
Next: $record->getTableName()