Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * I wish all ActiveRecord implementations used an interface. I'm proposing
- * this one with the intent that I can improve it, then submit changes to
- * conform a few existing ActiveRecord implementations that would allow them
- * to coincide.
- *
- * Email me if you'd like to help with this, or if you have an idea.
- *
- * @author Levi Morrison <[email protected]>
- */
- interface ActiveRecord {
- /**
- * Creates a new object. When save is called, it will insert a new record
- * into the database.
- * @param array $properties An associative array mapping column names to values.
- */
- public function __construct(array $properties = null);
- /**
- * Retrieves an object with the given $id from the database. The returned
- * object implements this interface.
- * @param int $id
- * @return ActiveRecord An object from the database, or null.
- */
- public static function find($id);
- /**
- * Deletes the record associated with $id from the database.
- * @param int $id
- * @return boolean Returns true if the data was successfully deleted.
- */
- public static function delete($id);
- /**
- * Saves the object to the database. If the object is a new instance, it
- * inserts a new record into the database. Calling farther saves on that
- * object results in updates, not new inserts.
- * If the object is not a new instance, it simply saves the data to the
- * database. For safety, you cannot update the primary key.
- *
- * A well-built implementation will only update or insert information that
- * is changed by the user, not all of the fields belonging to the class.
- *
- * @return boolean Returns true if the save was successful.
- */
- public function save();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment