/** * Queries the database * * @param string query * @return array|object */ public function query($query) { //Argument 1 must be a string or null Eden_Yahoo_Error::i()->argument(1, 'string', 'array', self::SELECT); if (!is_array($query)) { $query = array('q' => (string) $query); } else { foreach ($query as $key => $select) { $query[$key] = (string) $select; } $query = array('q' => json_encode($query)); } $query['access_token'] = $this->_token; $url = str_replace('+', '%20', self::YQL_URL . '?' . http_build_query($query + array('format' => 'json'))); $results = Eden_Curl::i()->setUrl($url)->setConnectTimeout(10)->setFollowLocation(true)->setTimeout(60)->verifyPeer(false)->setUserAgent(Eden_Facebook_Auth::USER_AGENT)->setHeaders('Expect')->getJsonResponse(); $this->_queries[] = array('query' => $query['q'], 'results' => $results); if (isset($results['error']['message'])) { Eden_Facebook_Error::i($query['q'] . $results['error']['message'])->trigger(); } return $results; }
/** * Stores this search and resets class. * Useful for multiple queries. * * @param scalar * @return this */ public function group($key) { Eden_Yahoo_Error::i()->argument(1, 'scalar'); if (is_null($this->_table)) { return $this; } $this->_group[$key] = array('table' => $this->_table, 'columns' => $this->_columns, 'filter' => $this->_filter, 'sort' => $this->_sort, 'start' => $this->_start, 'range' => $this->_range); $this->_table = NULL; $this->_columns = array(); $this->_filter = array(); $this->_sort = array(); $this->_start = 0; $this->_range = 0; return $this; }
/** * Limit clause * * @param string|int page * @param string|int length * @return this * @notes loads page and length into registry */ public function limit($page, $length) { //argument test Eden_Yahoo_Error::i()->argument(1, 'numeric')->argument(2, 'numeric'); //Argument 2 must be a number $this->_page = $page; $this->_length = $length; return $this; }