示例#1
0
 function set($var, $value)
 {
     // This function handles a SPECIAL CASE where the use_offset is queried for a ROPE object.  This is special because a ROPE has a different use_offset
     // for each end (end 'a' and end 'b'), which are serialized into a single STRING value for database storage.
     // If this set function is called and the special case does not apply, the 'set' function in the parent class will be invoked.
     $value = strtolower(mydb::cxn()->real_escape_string($value));
     switch ($var) {
         case 'use_offset':
             if ($value == "") {
                 $this->use_offset = 'a0,b0';
             } elseif (preg_match('/\\ba\\d{1,3},b\\d{1,3}\\b/', $value) != 1) {
                 throw new Exception('The USE OFFSET for a rope must include both the \'A\' end and the \'B\' end.');
             } else {
                 $this->use_offset = $value;
             }
         case 'use_offset_a':
             if ($value == "") {
                 $this->use_offset = 'a0,b0';
             }
             if ($this->var_is_int($value) && $value >= 0) {
                 $this->use_offset = 'a' . $value . ',b' . $this->get_use_offset('b');
             } else {
                 throw new Exception('The use-offset for end \'A\' must be a number greater than or equal to zero.');
             }
             break;
         case 'use_offset_b':
             if ($this->var_is_int($value) && $value >= 0) {
                 $this->use_offset = 'a' . $this->get_use_offset('a') . ',b' . $value;
             } else {
                 throw new Exception('The use-offset for end \'B\' must be a number greater than or equal to zero.');
             }
             break;
         default:
             parent::set($var, $value);
     }
     // End: switch()
 }