PHP-PDB: Datebook Files

Main Page
General
Basic Use
Custom Formats
Extra Info
Credits
Modules
Address Book
Datebook
DOC
List
Memo Pad
MobileDB
SmallBASIC
Todo
Examples
Bookmark Test
Spade
Twister
SourceForge
Download
Project Page
Mailing Lists
Bug Reporting

This class uses a completely different for for storing information about events. It is supposed to make things easier, but might be a bit complex to learn at first.

If you install a database created with this class onto your handheld, it will overwrite the one that already exists on your handheld. This is because a new database will have the same name as the current database on your handheld and you can't change the name of the database otherwise the application won't work. This is obviously irritating -- please keep this in mind. An ideal use for this PHP class would be for talking to a conduit, where the conduit would upload the current data, the server would parse it and add/modify/delete entries with this class, the server would send the modified file back to the conduit, and the conduit would replace the device's database with the modified one.

Including into your program

include 'php-pdb.inc';
include 'modules/datebook.inc';

Creating a new database

Since a datebook has a specified type, creator, and name, the class takes care of knowing what they are. Creation of a new datebook is a snap.
$DB = new PalmDatebook();

Writing the database

This is the same as the base class. See Basic Use for more information.

Loading the database

This is the same as the base class. See Basic Use for more information.

Other functions

GetRecordRaw()
SetRecordRaw()
Please see Basic Use for how to use these functions. You use both of these to get/set records in the database.
NewRecord()
Returns an array with some default data for a new Datebook record. Does not actually add the record. Use SetRecordRaw() for that.

Record Format

The data for the GetRecordRaw and the data returned from SetRecordRaw is a specially formatted array, as detailed below. Optional values can be set to '' or not defined. If an optional value is anything else (including zero), it is considered to be set.

KeyExampleDescription
StartTime2:00Starting time of the event, 24 hour format
Date2001-01-23Year, month, and day of the event
DescriptionEat At Joe'sThe title or the name of the event
EndTime13:00[Optional] Ending time of the event, 24 hour format.
Alarm5d[Optional] A number of units before the event to sound an alarm (m = minutes, h = hours, d = days)
RepeatSpecial[Optional] An array detailing how the event should repeat
NoteOrder a burger and fries[Optional] A note for the event
ExceptionsSpecial[Optional] Exceptions when the event should not happen
WhenChanged1[Optional] True if the "when info" for the event has changed.
Flags3[Optional] User flags for the event

EndTime must happen at or after StartTime. The time the event occurs may not pass midnight (0:00). If the event doesn't have a time (an all-day event), use '' or do not define StartTime and EndTime.

Exceptions are specified in an array consisting of dates the event occured and did not happen or should not be shown. Dates are in the format YYYY-MM-DD, just like the Date attribute of the record.

Repeating events are special, and the Repeat attribute of the record is set to an array.

No repeat (or just leave Repeat undefined):
$repeat['Type'] = PDB_DATEBOOK_REPEAT_NONE;
Daily repeating events:
$repeat['Type'] = PDB_DATEBOOK_REPEAT_DAILY;
$repeat['Frequency'] = FREQUENCY; // Explained below
$repeat['End'] = END_DATE; // Explained below
Weekly repeating events:
$repeat['Type'] = PDB_DATEBOOK_REPEAT_Weekly;
$repeat['Frequency'] = FREQUENCY; // Explained below
$repeat['End'] = END_DATE; // Explained below
$repeat['Days'] = DAYS; // Explained below
$repeat['StartOfWeek'] = SOW; // Explained below
"Monthly by day" repeating events: (happens on a specific weekday)
$repeat['Type'] = PDB_DATEBOOK_REPEAT_MONTH_BY_DAY;
$repeat['Frequency'] = FREQUENCY; // Explained below
$repeat['End'] = END_DATE; // Explained below
$repeat['WeekNum'] = WEEKNUM; // Explained below
$repeat['DayNum'] = DAYNUM; // Explained below
"Monthly by date" repeating events: (happens on a specific numbered day)
$repeat['Type'] = PDB_DATEBOOK_REPEAT_MONTH_BY_DATE;
$repeat['Frequency'] = FREQUENCY; // Explained below
$repeat['End'] = END_DATE; // Explained below
Yearly repeating events:
$repeat['Type'] = PDB_DATEBOOK_REPEAT_YEARLY;
$repeat['Frequency'] = FREQUENCY; // Explained below
$repeat['End'] = END_DATE; // Explained below
FREQUENCY
The frequency of the event. If it is a daily event and you want it to happen every other day, set Frequency to 2. This will default to 1 if not specified.
END_DATE
The last day, month, and year on which the event occurs. Format is YYYY-MM-DD. If not specified, no end date will be set. If the record was loaded from a file and there was no end date for a repeating event, this array element will not be set.
DAYS
What days during the week the event occurs. This is a string of numbers from 0 to 6. I'm not sure if 0 is Sunday or if 0 is the start of the week from the preferences. If you have a weekly repeating event and you want it to repeat on Thursday, you set this to "4".
SOW
As quoted from P5-Palm:
"I'm not sure what this is, but the Datebook app appears to perform some hairy calculations involving this."
WEEKNUM
The number of the week on which the event occurs. 5 is the last week of the month. 0 is the first.
DAYNUM
The day of the week on which the event occurs. Again, I don't know if 0 is Sunday or if 0 is the start of the week from the preferences.

There are also two mysterious 'unknown' fields for the repeat event and they will be populated if the database is loaded from a file. They will otherwise default to 0. They are 'unknown1' and 'unknown2'.

Example

// Create an instance of the class
$pdb = new PalmDatebook();

// Create a repeating event that happens every other Friday.
// I want it to be an all-day event that says "Pay Day!"
$Repeat = array(
   "Type" => PDB_DATEBOOK_REPEAT_WEEKLY,
   "Frequency" => 2,
   "Days" => "5",
   "StartOfWeek" => 0
);
$Record = array(
   "Date" => "2001-11-2",
   "Description" => "Pay Day!",
   "Repeat" => $Repeat
);

// Add the record to the datebook
$pdb->SetRecordRaw($Record);

// Advance to the next record just in case we want to add more events
$pdb->GoToRecord("+1");


SourceForge Logo ©opyright 2001, Tyler Akins ()
All names, trademarks, etc. are property of their respective owners.