Hi Chetan,
That page includes sections with code samples in different languages; check the PHP one:
http://www.epochconverter.com/programming/functions-php.php
You could also take a look at the Moodle Enrolment plugins documentation page and at the links at the See also section of the Database schema introduction page.