Ejemplo n.º 1
0
 function SearchCompleteValues(&$form, $text, &$found)
 {
     $error = '';
     $found = array();
     if (strlen($complete_expression = MetabaseBeginsWith($this->connection, $text)) == 0) {
         return 'it was not possible to build the complete query expression: ' . MetabaseError($this->connection);
     }
     if (!strcmp($complete_values_query = str_replace('{BEGINSWITH}', $complete_expression, $this->complete_values_query), $this->complete_values_query)) {
         return 'the complete values query does not contain the {BEGINSWITH} mark to insert the complete expression';
     }
     if (strlen($text) && $this->complete_values_limit) {
         MetabaseSetSelectedRowRange($this->connection, 0, $this->complete_values_limit);
     }
     if ($r = MetabaseQuery($this->connection, $complete_values_query)) {
         for ($l = 0; !MetabaseEndOfResult($this->connection, $r); $l++) {
             if (!MetabaseFetchResultArray($this->connection, $r, $d, $l)) {
                 $error = 'Could not retrieve the complete values: ' . MetabaseError($this->connection);
                 break;
             }
             $found[$d[0]] = $this->FormatCompleteValue($d);
         }
         MetabaseFreeResult($this->connection, $r);
     } else {
         $error = 'Complete values query execution failed: ' . MetabaseError($this->connection);
     }
     return $error;
 }
Ejemplo n.º 2
0
 $data["subscribed"] = 0;
 $data["quota"] = 0;
 $data["weight"] = 0;
 $data["access_date"] = MetabaseToday();
 $data["access_time"] = MetabaseTime();
 $data["approved"] = MetabaseNow();
 for ($v = 0, Reset($values); $v < count($values); Next($values), $v++) {
     $data["user_name"] = $values[$data["user_id"] = Key($values)];
     if (!InsertTestValues($database, $prepared_query, $data)) {
         $success = 0;
         break;
     }
 }
 MetabaseFreePreparedQuery($database, $prepared_query);
 if ($success) {
     $queries = array(MetabaseBeginsWith($database, "%") => array(1), MetabaseEndsWith($database, "%") => array(3), MetabaseContains($database, "%") => array(1, 2, 3, 9), "NOT " . MetabaseContains($database, "%") => array(4, 5, 6, 7, 8), MetabaseBeginsWith($database, "_") => array(5), MetabaseEndsWith($database, "_") => array(7), MetabaseContains($database, "_") => array(5, 6, 7, 9), "NOT " . MetabaseContains($database, "_") => array(1, 2, 3, 4, 8), MetabaseMatchPattern($database, array("begin", "%", "end")) => array(2, 4, 6, 8), MetabaseMatchPattern($database, array("begin", "_", "end")) => array(2, 6), MetabaseMatchPattern($database, array("%", "%", "end")) => array(1), MetabaseMatchPattern($database, array("_", "%", "end")) => array(5), MetabaseMatchPattern($database, array(" _@%\\ ]['?*")) => array(9));
     for ($q = 0, Reset($queries); $q < count($queries); Next($queries), $q++) {
         $condition = Key($queries);
         if (!MetabaseQueryColumn($database, "SELECT user_id FROM users WHERE user_name " . $condition . " ORDER BY user_id", $rows, "integer")) {
             $success = 0;
             break;
         }
         if (count($queries[$condition]) != count($rows)) {
             $pass = 0;
         } else {
             for ($v = 0; $v < count($rows); $v++) {
                 if ($queries[$condition][$v] != $rows[$v]) {
                     $pass = 0;
                     break;
                 }
             }