-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSolr.php
61 lines (55 loc) · 1.58 KB
/
Solr.php
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
<?php
namespace sammaye\solr;
use Yii;
/**
* This is a static hleper for Solr, this is specific to things that have been done
* in our Solr deployment, however, others may find it useful, or not, it is upto you to use it.
*/
class Solr
{
/**
* Make sure not to set value if it is just an _ . This means that the value was missing in the Solr search result.
* @param string $value The value to set in the bo
*/
public static function string($value)
{
if($value !== '_'){
return $value;
}
}
/**
* Make sure not to set value if it is just an 0000-01-01T00:00:00Z . This means that value is
* a null representation.
*
* Convert back to a MySql date representation
* @param string $value The value to set in the bo
*/
public static function date($value)
{
if($value != '0000-01-01T00:00:00Z' && $value != '1-01-01T00:00:00Z' && $value != '0001-01-01T00:00:00Z' ){
//convert back to Mysql representation of a date
$value = date('Y-m-d', strtotime($value));
return $value;
}
}
/**
* Make sure not to set value if it is just an 0 . This means that the value was missing in the Solr search result.
* @param string $value The value to set in the bo
*/
public static function int($value)
{
if($value != '0'){
return $value;
}
}
/**
* Make sure not to set value if it is just an 0 . This means that the value was missing in the Solr search result.
* @param string $value The value to set in the bo
*/
public static function float($value)
{
if($value != '0.00'){
return $value;
}
}
}