-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathARShortHand.php
More file actions
79 lines (65 loc) · 1.33 KB
/
ARShortHand.php
File metadata and controls
79 lines (65 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Shorthand functions for query building
*
* @package activerecord
* @author Integry Systems
*/
/**
* Create field handle from string
*
* f('Product.ID') is the same as new ARFieldHandle('Product', 'ID')
**/
function f($field)
{
if ($field instanceof ARFieldHandleInterface)
{
return $field;
}
if (!strpos($field, '.'))
{
return new ARExpressionHandle($field);
}
list($tableName, $fieldName) = explode('.', $field);
return new ARFieldHandle($tableName, $fieldName);
}
function select()
{
return new ARSelectFilter(Condition::mergeFromArray(func_get_args()));
}
function lt($field, $secondField)
{
return new LessThanCond(f($field), $secondField);
}
function gt($field, $secondField)
{
return new MoreThanCond(f($field), $secondField);
}
function lte($field, $secondField)
{
return new OperatorCond(f($field), $secondField, '<=');
}
function gte($field, $secondField)
{
return new OperatorCond(f($field), $secondField, '>=');
}
function eq($field, $secondField)
{
return new EqualsCond(f($field), $secondField);
}
function neq($field, $secondField)
{
return new NotEqualsCond(f($field), $secondField);
}
function isnull($field)
{
return new IsNullCond(f($field));
}
function isnotnull($field)
{
return new IsNotNullCond(f($field));
}
function IN($field, $array)
{
return new INCond(f($field), $array);
}