plugin.php - extend constraint
[email protected] (LuigiT) Wed, 16 Apr 2003 05:46:58 GMT
| Newsgroups | gmane.comp.web.phpopentracker.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello
I have add some instruction to plugin.php for this purpose:
- use more rules to one constraint
es. host = A OR host = B
- != condition (es. host != A) with AND condition (es. host != A AND
host != B) only for some constraint
Note: old api request work correctly
Syntax request:
'constraints' => array( constraintN => array (value, '=/!='))
where N is number of same constraint
es.
'constraints' => array(
'user_agent0' => array(A,'='),
'user_agent1' => B,
'operating_system0' => array(C,'!='),
'operating_system1' => D,
'entry_document' => E
)
that means:
((user_agent = A OR user_agent = B) AND
(operating_system = C AND operating_system = D) AND
(entry_document = E))
modify to plugin.php v 1.18 2003/02/09 08:21:13 bergmann
$field_bf = '';
foreach ($constraints as $campo => $value_new) {
//extract field from constraint
$field = substr($campo, 0, strcspn ( $campo, "0123456789"));
//compatibility with old version
if (is_array($value_new)) {
$value = $value_new[0];
if ($field_bf != $field) {
$comp = $value_new[1];
}
}
else {
$value = $value_new;
$comp = "=";
}
//connecting rules
if ($field_bf != $field) {
if ($field_bf != '') {
$constraint .= ") AND (";
}
else {
$constraint .= " AND ((";
}
$field_bf = $field;
}
else {
if ($comp === "=")
$constraint .= " OR ";
else
$constraint .= " AND ";
}
// following line are identical, except:
// - constraint's sprintf where initial AND is eliminate
// - some constraint's sprintf where '=' is replace by $comp
..
$constraint .= sprintf(
" accesslog%s.document_id = %d AND accesslog%s.entry_document = '1'",
...
$constraint .= sprintf(
' accesslog%s.document_id = %d AND accesslog%s.exit_target_id <> 0',
....
$constraint .= sprintf(
' accesslog%s.exit_target_id = %d',
...
$constraint .= sprintf(
' visitors.%s_id %s %d',
$field,
$comp,
$value
...
// at the end of swith/case
//close rules
if ($field_bf != '') {
$constraint .= "))";
}
Other feature to add:
- connection different constraint with OR condition
es. host = A OR user_agent = C (is useful??)
- apply '!=' to all constraint (is useful??)
Bye
Luigi Tuberga
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf