-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathQuery.php
More file actions
executable file
·84 lines (77 loc) · 2.35 KB
/
Query.php
File metadata and controls
executable file
·84 lines (77 loc) · 2.35 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
80
81
82
83
84
<?php
/**
* Query is use to get Entries from specific ContentType
*
* PHP version 5
*
* @category PHP
* @package Contentstack
* @author Uttam K Ukkoji <uttamukkoji@gmail.com>
* @author Rohit Mishra <rhtmishra4545@gmail.com>
* @copyright 2012-2021 Contentstack. All Rights Reserved
* @license https://github.com/contentstack/contentstack-php/blob/master/LICENSE.txt MIT Licence
* @link https://pear.php.net/package/contentstack
* */
namespace Contentstack\Stack\ContentType;
use Contentstack\Stack\BaseQuery;
use Contentstack\Support\Utility;
/**
* Class Query
*
* @category PHP
* @package Contentstack
* @author Uttam K Ukkoji <uttamukkoji@gmail.com>
* @author Rohit Mishra <rhtmishra4545@gmail.com>
* @copyright 2012-2021 Contentstack. All Rights Reserved
* @license https://github.com/contentstack/contentstack-php/blob/master/LICENSE.txt MIT Licence
* @link https://pear.php.net/package/contentstack
* */
#[\AllowDynamicProperties]
class Query extends BaseQuery
{
var $operation;
var $_query;
/**
* Query Class to initalize your Query
*
* @param string $data - data for query
* @param string $type - type of query
* */
public function __construct($data = '', $type = '')
{
$this->_query = array();
$this->type = $type;
parent::__construct($data, $this);
}
/**
* Get all entries based on the specified subquery
*
* @return Request
* */
public function find()
{
$this->operation = __FUNCTION__;
if ($this->type == 'assets') {
return Utility::contentstackRequest($this->assets->stack, $this, 'assets');
} else if ($this->type == 'contentType') {
return Utility::contentstackRequest($this->contentType->stack, $this);
}
}
/**
* Get single entry based on the specified subquery
*
* @deprecated since verion 1.1.0
*
* @return Request
* */
public function findOne()
{
$this->operation = __FUNCTION__;
$this->_query['limit'] = 1;
if ($this->type == 'assets') {
return Utility::contentstackRequest($this->assets->stack, $this, 'assets');
} elseif ($this->type == 'contentType') {
return Utility::contentstackRequest($this->contentType->stack, $this);
}
}
}