Sms_carrier.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Table Definition for sms_carrier
  4. */
  5. require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
  6. class Sms_carrier extends Managed_DataObject
  7. {
  8. ###START_AUTOCODE
  9. /* the code below is auto generated do not remove the above tag */
  10. public $__table = 'sms_carrier'; // table name
  11. public $id; // int(4) primary_key not_null
  12. public $name; // varchar(64) unique_key
  13. public $email_pattern; // varchar(191) not_null not 255 because utf8mb4 takes more space
  14. public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
  15. public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
  16. /* the code above is auto generated do not remove the tag below */
  17. ###END_AUTOCODE
  18. function toEmailAddress($sms)
  19. {
  20. return sprintf($this->email_pattern, $sms);
  21. }
  22. public static function schemaDef()
  23. {
  24. return array(
  25. 'fields' => array(
  26. 'id' => array('type' => 'int', 'not null' => true, 'description' => 'primary key for SMS carrier'),
  27. 'name' => array('type' => 'varchar', 'length' => 64, 'description' => 'name of the carrier'),
  28. 'email_pattern' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'sprintf pattern for making an email address from a phone number'),
  29. 'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'),
  30. 'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
  31. ),
  32. 'primary key' => array('id'),
  33. 'unique keys' => array(
  34. 'sms_carrier_name_key' => array('name'),
  35. ),
  36. );
  37. }
  38. }