new Blog - jcobban/Genealogy GitHub Wiki

new Blog($parms)

Up: class Blog

The constructor for an instance of Blog 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('bl_index' => integer) specifies the unique numeric key of the existing record in the table that is to be used to initialize the new instance.
  • To create a new Blog entry supply the fields to initialize the record, excluding 'bl_index' and 'bl_datetime', which are set by the constructor. For example to send a message to a specific user:
$user   = new User(array('email'        => '[email protected]'));
$blog	= new Blog(array('table'	=> 'Users',
			 'keyvalue'	=> $user['id'],
			 'text'		=> $message));
  • To associate a new Blog entry with a particular individual in the family tree it is necessary to identify which of the two unique keys of the Person record to use:
$blog	= new Blog(array('table'	=> 'Persons',
		         'keyname'	=> 'IDIR',
			 'keyvalue'	=> $idir,
			 'text'		=> $message));
  • A Blog record can even be associated with another Blog record which is used to associate responses or followup messages:
$blog	= new Blog(array('table'	=> 'Blogs',
			 'keyvalue'	=> $blid,
			 'subject'	=> $subject,
			 'text'		=> $message));

The constructor adds error messages to $record->msg if it is unable to complete due to bad parameters.

Next: class Census