new Source
James Cobban edited this page Jan 3, 2021
·
2 revisions
Up: class Source
The constructor for an instance of Source takes one parameter:
parameter | description |
---|---|
$parms | identifies the database record to be associated with this instance. This is an associative array. |
$parms may be:
- An associative array containing all of the fields in a record as obtained by a database SELECT.
-
array('srcname' => $srcname)
specifies the unique source name value of the record in the table that is to be used to initialize the new instance. -
array('idsr' => $idsr)
specifies the unique numeric key of the record in the table that is to be used to initialize the new instance. This is used to link other records, for example class Citation, to this Source.
In addition when creating an instance of Source the initial values for other fields may be supplied. Any fields not explicitly set take on their default values. If for creating a new instance the value for "srcname"
is supplied but the value of "srctitle"
is not supplied then "srctitle"
is initialized to the value of "srcname"
.
The instance of Source identified by the internal numeric key may also be obtained by using the $familyTree->getSource($idsr)
The constructor adds error messages to $record->msg
if it is unable to complete due to bad parameters.
Examples:
new Source(); // create new empty entry
new Source(array('idsr' => 127));
$familyTree->getSource(127); // factory method
new Source(array('srcname' => 'London, England'));
new Source(array('srcname' => 'Principia Mathematica',
'srcauthor' => 'Isaac Newton',
'idst' => Source::ST_BOOK));
Next: $source->getName()