11 * to license@zend.com so we can send you a copy immediately. |
11 * to license@zend.com so we can send you a copy immediately. |
12 * |
12 * |
13 * @category Zend |
13 * @category Zend |
14 * @package Zend_Cloud |
14 * @package Zend_Cloud |
15 * @subpackage DocumentService |
15 * @subpackage DocumentService |
16 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
16 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @license http://framework.zend.com/license/new-bsd New BSD License |
17 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 */ |
18 */ |
19 |
19 |
20 /* |
20 /* |
21 * @see Zend_Cloud_DocumentService_QueryAdapter |
21 * @see Zend_Cloud_DocumentService_QueryAdapter |
22 */ |
22 */ |
23 require_once 'Zend/Cloud/DocumentService/QueryAdapter.php'; |
23 require_once 'Zend/Cloud/DocumentService/QueryAdapter.php'; |
24 |
24 |
25 /** |
25 /** |
26 * Class implementing Query adapter for working with Azure queries in a |
26 * Class implementing Query adapter for working with Azure queries in a |
27 * structured way |
27 * structured way |
28 * |
28 * |
29 * @todo Look into preventing a query injection attack. |
29 * @todo Look into preventing a query injection attack. |
30 * @category Zend |
30 * @category Zend |
31 * @package Zend_Cloud |
31 * @package Zend_Cloud |
32 * @subpackage DocumentService |
32 * @subpackage DocumentService |
33 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
33 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
35 */ |
35 */ |
36 class Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
36 class Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
37 implements Zend_Cloud_DocumentService_QueryAdapter |
37 implements Zend_Cloud_DocumentService_QueryAdapter |
38 { |
38 { |
39 /** |
39 /** |
40 * Azure concrete query |
40 * Azure concrete query |
41 * |
41 * |
42 * @var Zend_Service_WindowsAzure_Storage_TableEntityQuery |
42 * @var Zend_Service_WindowsAzure_Storage_TableEntityQuery |
43 */ |
43 */ |
44 protected $_azureSelect; |
44 protected $_azureSelect; |
45 |
45 |
46 /** |
46 /** |
47 * Constructor |
47 * Constructor |
48 * |
48 * |
49 * @param null|Zend_Service_WindowsAzure_Storage_TableEntityQuery $select Table select object |
49 * @param null|Zend_Service_WindowsAzure_Storage_TableEntityQuery $select Table select object |
50 * @return void |
50 * @return void |
51 */ |
51 */ |
52 public function __construct($select = null) |
52 public function __construct($select = null) |
53 { |
53 { |
54 if (!$select instanceof Zend_Service_WindowsAzure_Storage_TableEntityQuery) { |
54 if (!$select instanceof Zend_Service_WindowsAzure_Storage_TableEntityQuery) { |
55 require_once 'Zend/Service/WindowsAzure/Storage/TableEntityQuery.php'; |
55 require_once 'Zend/Service/WindowsAzure/Storage/TableEntityQuery.php'; |
56 $select = new Zend_Service_WindowsAzure_Storage_TableEntityQuery(); |
56 $select = new Zend_Service_WindowsAzure_Storage_TableEntityQuery(); |
57 } |
57 } |
58 $this->_azureSelect = $select; |
58 $this->_azureSelect = $select; |
59 } |
59 } |
60 |
60 |
61 /** |
61 /** |
62 * SELECT clause (fields to be selected) |
62 * SELECT clause (fields to be selected) |
63 * |
63 * |
64 * Does nothing for Azure. |
64 * Does nothing for Azure. |
65 * |
65 * |
66 * @param string $select |
66 * @param string $select |
67 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
67 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
68 */ |
68 */ |
69 public function select($select) |
69 public function select($select) |
70 { |
70 { |
71 return $this; |
71 return $this; |
72 } |
72 } |
73 |
73 |
74 /** |
74 /** |
75 * FROM clause (table name) |
75 * FROM clause (table name) |
76 * |
76 * |
77 * @param string $from |
77 * @param string $from |
78 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
78 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
79 */ |
79 */ |
80 public function from($from) |
80 public function from($from) |
81 { |
81 { |
82 $this->_azureSelect->from($from); |
82 $this->_azureSelect->from($from); |
83 return $this; |
83 return $this; |
84 } |
84 } |
85 |
85 |
86 /** |
86 /** |
87 * WHERE clause (conditions to be used) |
87 * WHERE clause (conditions to be used) |
88 * |
88 * |
89 * @param string $where |
89 * @param string $where |
90 * @param mixed $value Value or array of values to be inserted instead of ? |
90 * @param mixed $value Value or array of values to be inserted instead of ? |
91 * @param string $op Operation to use to join where clauses (AND/OR) |
91 * @param string $op Operation to use to join where clauses (AND/OR) |
92 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
92 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
93 */ |
93 */ |
98 $value = array($value); |
98 $value = array($value); |
99 } |
99 } |
100 $this->_azureSelect->where($where, $value, $op); |
100 $this->_azureSelect->where($where, $value, $op); |
101 return $this; |
101 return $this; |
102 } |
102 } |
103 |
103 |
104 /** |
104 /** |
105 * WHERE clause for item ID |
105 * WHERE clause for item ID |
106 * |
106 * |
107 * This one should be used when fetching specific rows since some adapters |
107 * This one should be used when fetching specific rows since some adapters |
108 * have special syntax for primary keys |
108 * have special syntax for primary keys |
109 * |
109 * |
110 * @param array $value Row ID for the document (PartitionKey, RowKey) |
110 * @param array $value Row ID for the document (PartitionKey, RowKey) |
111 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
111 * @return Zend_Cloud_DocumentService_Adapter_WindowsAzure_Query |
112 */ |
112 */ |
113 public function whereId($value) |
113 public function whereId($value) |
114 { |
114 { |