示例#1
0
 public function ne($other)
 {
     return ne($this, $other);
 }
示例#2
0
function check_not_empty($string)
{
    return ne($string);
}
示例#3
0
文件: Ldo.php 项目: Rongya/LazyPHP4
 public function __call($name, $arguments)
 {
     if (!isset($this->table)) {
         throw new \Exception("LDO未绑定数据表");
     }
     $reg = '/(get|find)([A-Z_]+[a-z0-9_]*)By([A-Z_]+[a-z0-9_]*)(Limit)*/s';
     if (preg_match($reg, $name, $out)) {
         //print_r($out);
         $type = strtolower(t($out[1]));
         $select = strtolower(t($out[2]));
         if (isset($out[3])) {
             $where = strtolower(t($out[3]));
         } else {
             $where = '';
         }
         if (isset($out[4]) && strtolower(t($out[4])) == 'limit') {
             $limit = true;
         } else {
             $limit = false;
         }
         switch ($select) {
             case 'data':
                 $array = array_shift($arguments);
                 if (is_array($array)) {
                     foreach ($array as $value) {
                         $select_array[] = '`' . $value . '`';
                     }
                     if (isset($select_array)) {
                         $select_sql = join(' , ', $select_array);
                     } else {
                         $select_sql = ' * ';
                     }
                 } else {
                     $select_sql = ' * ';
                 }
                 break;
             case 'all':
                 $select_sql = ' * ';
                 break;
             default:
                 $select_sql = ' `' . $select . '` ';
                 break;
         }
         if (ne($where)) {
             if ($where == 'nothing') {
                 $where_sql = " 1 ";
             } elseif ($where == 'array') {
                 $array = array_shift($arguments);
                 if (is_array($array)) {
                     foreach ($array as $key => $value) {
                         $where_array[] = "`" . $key . "` = '" . s($value) . "'";
                     }
                     if (isset($where_array)) {
                         $where_sql = join(' AND ', $where_array);
                     } else {
                         $where_sql = ' 1 ';
                     }
                 } else {
                     $where_sql = ' 1 ';
                 }
             } else {
                 $value = array_shift($arguments);
                 $where_sql = " `" . $where . "` = '" . s($value) . "' ";
             }
         }
         if ($limit) {
             if ($limit_info = array_shift($arguments)) {
                 if (is_array($limit_info)) {
                     $limit_sql = " LIMIT " . $limit_info[0] . " , " . $limit_info[1];
                 } elseif (ne($limit_info)) {
                     $limit_sql = " LIMIT " . $limit_info;
                 } else {
                     $limit_sql = " ";
                 }
             } else {
                 $limit_sql = " ";
             }
         } else {
             $limit_sql = " ";
         }
         $sql = "SELECT {$select_sql} FROM `{$this->table}` WHERE {$where_sql} {$limit_sql}";
         //echo $sql . "<br/>";
         return $this->db->getData($sql);
     } else {
         throw new \Exception("Method not exists" . $name);
     }
 }
 /**
  * Tests whether this multiset is equal to the specified multiset.
  * It is assumed that the specified multiset is an instance of
  * the MultisetAsLinkedList class.
  *
  * @param IMultiset $multiset The multiset to compare with this multiset.
  * @return boolean True if the multisets are equal; false otherwise.
  */
 public function eq(IComparable $set)
 {
     if ($this->getClass() != $set->getClass()) {
         throw new TypeError();
     }
     if ($this->universeSize != $set->universeSize) {
         throw new ArgumentError();
     }
     $p = $this->list->getHead();
     $q = $set->list->getHead();
     while ($p !== NULL && $q !== NULL) {
         if (ne($p->getDatum(), $q->getDatum())) {
             return false;
         }
         $p = $p->getNext();
         $q = $q->getNext();
     }
     if ($p !== NULL || $q !== NULL) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Withdraws the specified object from this chained scatter table.
  *
  * @param object IComparable $obj The object to be withdrawn.
  */
 public function withdraw(IComparable $obj)
 {
     if ($this->count == 0) {
         throw new ContainerEmptyException();
     }
     $i = $this->h($obj);
     while ($i != self::NIL && ne($obj, $this->array[$i]->object)) {
         $i = $this->array[$i]->next;
     }
     if ($i == self::NIL) {
         throw new ArgumentError();
     }
     for (;;) {
         $j = $this->array[$i]->next;
         while ($j != self::NIL) {
             $h = $this->h($this->array[$j]->object);
             $contained = false;
             for ($k = $this->array[$i]->next; $k != $this->array[$j]->next && !$contained; $k = $this->array[$k]->next) {
                 if ($k == $h) {
                     $contained = true;
                 }
             }
             if (!$contained) {
                 break;
             }
             $j = $this->array[$j]->next;
         }
         if ($j == self::NIL) {
             break;
         }
         $this->array[$i]->object = $this->array[$j]->object;
         $i = $j;
     }
     $this->array[$i]->object = NULL;
     $this->array[$i]->next = self::NIL;
     for ($j = ($i + $this->getLength() - 1) % $this->getLength(); $j != $i; $j = ($j + $this->getLength() - 1) % $this->getLength()) {
         if ($this->array[$j]->next == $i) {
             $this->array[$j]->next = self::NIL;
             break;
         }
     }
     --$this->count;
 }