Advertisement
Guest User

Untitled

a guest
Dec 10th, 2013
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1.  
  2. class Identifier extends DataObject {
  3.  
  4.     static $db = array(
  5.         'Name' => 'Varchar(255)',
  6.         'Inc' => 'Int'
  7.     );
  8.  
  9.     public static function next_id($name) {
  10.         if ($name) {
  11.             $id = DataObject::get_one('Identifier', "Name = '$name'");
  12.  
  13.             if ($id) {
  14.                 $id->Inc+=1;
  15.             } else {
  16.                 $id = new Identifier();
  17.  
  18.                 $id->Name = $name;
  19.                 $id->Inc = 20;
  20.             }
  21.  
  22.             $id->write();
  23.             return $id->Inc;
  24.         }
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement