Source for file TableEntityQuery.php
Documentation is available at TableEntityQuery.php
* Copyright (c) 2009 - 2011, RealDolmen
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of RealDolmen nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @package Microsoft_WindowsAzure
* @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
* @license http://phpazure.codeplex.com/license
* @version $Id: Blob.php 14561 2009-05-07 08:05:12Z unknown $
* @package Microsoft_WindowsAzure
* @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
* @license http://phpazure.codeplex.com/license
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
* @param string $name Table name to select entities from
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
public function from($name)
* @param string $value Partition key to query for
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
* @param string $value Row key to query for
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
* @param string $condition Condition, can contain question mark(s) (?) for parameter insertion.
* @param string|array$value Value(s) to insert in question mark (?) parameters.
* @param string $cond Condition for the clause (and/or/not)
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
public function where($condition, $value = null, $cond = '')
$condition = $this->_quoteInto($condition, $value);
} else if ($cond !== '') {
$this->_where[] = $cond . $condition;
* Add where clause with AND condition
* @param string $condition Condition, can contain question mark(s) (?) for parameter insertion.
* @param string|array$value Value(s) to insert in question mark (?) parameters.
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
public function andWhere($condition, $value = null)
return $this->where($condition, $value, 'and');
* Add where clause with OR condition
* @param string $condition Condition, can contain question mark(s) (?) for parameter insertion.
* @param string|array$value Value(s) to insert in question mark (?) parameters.
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
public function orWhere($condition, $value = null)
return $this->where($condition, $value, 'or');
* @param string $column Column to sort by
* @param string $direction Direction to sort (asc/desc)
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
public function orderBy($column, $direction = 'asc')
$this->_orderBy[] = $column . ' ' . $direction;
* @param int $top Top to fetch
* @return Microsoft_WindowsAzure_Storage_TableEntityQuery
public function top($top = null)
* Assembles the query string
* @param boolean $urlEncode Apply URL encoding to the query string
$query[] = '$filter=' . ($urlEncode ? self::encodeQuery($filter) : $filter);
$query[] = '$orderby=' . ($urlEncode ? self::encodeQuery($orderBy) : $orderBy);
$query[] = '$top=' . $this->_top;
if (count($query) != 0) {
* @param boolean $includeParentheses Include parentheses? ()
if ($includeParentheses) {
$identifier .= 'PartitionKey=\'' . self::encodeQuery($this->_partitionKey) . '\'';
$identifier .= 'RowKey=\'' . self::encodeQuery($this->_rowKey) . '\'';
return $this->_from . $identifier;
if ($queryString !== '') {
$assembledQuery .= $queryString;
* Quotes a variable into a condition
* @param string $text Condition, can contain question mark(s) (?) for parameter insertion.
* @param string|array$value Value(s) to insert in question mark (?) parameters.
protected function _quoteInto($text, $value = null)
while(strpos($text, '?') !== false) {
* @param string $query Query to encode
* @return string Encoded query
|