Welcome Guest, Not a member yet? Register   Sign In
Auto_Model PHP5
#5

[eluser]Sam Dark[/eluser]
Code:
abstract class AutomodelBehavior {
  /**
   * Enter description here...
   *
   * @param AutoModel $model
   */
  function on_insert($model){}
  
  /**
   * Enter description here...
   *
   * @param AutoModel $model
   */
  function on_update($model){}
  
  /**
   * Enter description here...
   *
   * @param AutoModel $model
   */
  function on_delete($model){}
}

/**
* Automatically fills updated_on and created_on with current unix timestamps
* //TODO: timezones support
*/
class TimestampableBehavior extends AutomodelBehavior {
  function on_insert($model){
    $model->db->set($model->table.'.created_on', time());
  }
  
  function on_update($model){
    $model->db->set($model->table.'.updated_on', time());
  }
}


Messages In This Thread
Auto_Model PHP5 - by El Forum - 08-22-2008, 11:11 PM
Auto_Model PHP5 - by El Forum - 08-22-2008, 11:12 PM
Auto_Model PHP5 - by El Forum - 08-22-2008, 11:59 PM
Auto_Model PHP5 - by El Forum - 08-25-2008, 03:05 AM
Auto_Model PHP5 - by El Forum - 08-25-2008, 03:05 AM
Auto_Model PHP5 - by El Forum - 08-25-2008, 03:06 AM
Auto_Model PHP5 - by El Forum - 08-25-2008, 03:24 AM
Auto_Model PHP5 - by El Forum - 08-25-2008, 03:38 AM
Auto_Model PHP5 - by El Forum - 08-25-2008, 11:06 AM
Auto_Model PHP5 - by El Forum - 03-30-2009, 12:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB