获取数据

@since 0.0.1
@param {string} $action 接口名称
@param {array} $query 参数
@param {string|array} [$data] 数据
@return {array}
333747
private function getData($action, $query, $data = null) {
		$_result = $this->curl($this->getApiUrl($action, $query), $data);

		if(!$_result) {
			$this->errcode = '503';
			$this->errmsg = '接口服务不可用';
		}

		$result = json_decode($_result, true);
		if(json_last_error()) {
			if($extension = $this->getExtension($this->getMimeType($_result, true))) {
				$result = ['content' => $_result, 'extension' => $extension];
			} else {
				$this->errcode = '503';
				$this->errmsg = '数据不合法';
			}
		} else if(isset($result['errcode']) && isset($result['errmsg'])) {
			$this->errcode = $result['errcode'];
			$this->errmsg = $this->getMessage($result['errmsg']);
		}

		return $result;
	}
1012809
public function query($query, $data = null){

        try {

            if(!$data){
                return parent::query($query);
            }//if

            $stmt = parent::prepare($query);

            if(!is_array($data)){
                $data = Array($data);
            }//if

            $stmt->execute($data);

            return $stmt;

        } catch(\PDOException $e){
            TRIGGER_ERROR("DB:: Query Error | {$query}\n".$e->getMessage() . "\n" . $e->getTraceAsString(),E_USER_WARNING);
            throw new \Disco\exceptions\DBQuery($e->getMessage(), (int)$e->getCode());
        }//catch

    }
743980
public function remove($action, $id = null)
    {
        /** @var $query \eZ\Publish\Core\Persistence\Database\DeleteQuery */
        $query = $this->dbHandler->createDeleteQuery();
        $query->deleteFrom(
            $this->dbHandler->quoteTable($this->table)
        )->where(
            $query->expr->eq(
                $this->dbHandler->quoteColumn('action'),
                $query->bindValue($action, null, \PDO::PARAM_STR)
            )
        );

        if ($id !== null) {
            $query->where(
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('is_alias'),
                        $query->bindValue(0, null, \PDO::PARAM_INT)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('id'),
                        $query->bindValue($id, null, \PDO::PARAM_INT)
                    )
                )
            );
        }

        $query->prepare()->execute();
    }
211075
public function query(
		string $query, 
		$values=null, 
		$table=null
	) {
		// set the main action
		$this->action('QUERY');
		// set the table
		$this->Table = $table;
		// set the query
		$this->Query = $query;
		// set the array of values
		$this->Values = $values;
		// detetect the action
		$action = substr($query, 0, 6);
		// if action can alter a table (INSERT, UPDATE, DELETE)
		if(in_array($action, array('INSERT', 'UPDATE', 'DELETE', 'SELECT'))) {
			// in case of INSERT
			if($action == 'INSERT') {
				// explode after INTO
				list(,$table) = explode('INTO ', $this->Query);
				// isolate the table name
				list($this->Table) = explode(' ', $table);
			}
			// in case of UPDATE
			elseif($action == 'UPDATE') {
				// explode after UPDATE
				list(,$table) = explode('UPDATE ', $this->Query);
				// isolate the table name
				list($this->Table) = explode(' ', $table);
			}
			// in case of DELETE or SELECT
			elseif($action == 'DELETE' || $action == 'SELECT') {
				// explode after FROM 
				list(,$table) = explode('FROM ', $this->Query);
				// isolate the table name
				list($this->Table) = explode(' ', $table);
			}
			// clean the table name from any quotes
			$this->Table = trim($this->Table, '\'/"`');
		}
		// return self to the next method
		return $this;
	}
355055
public function query ($query, $data = array(), $entity = null)
		{
			if ($this->cache->isCached($query)) {
				return $this->cache->getCachedResult($query);
			} else {
				try {
					$statement = $this->database->prepare((string) $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
					$result = $statement->execute($data);
					$this->lastQuery = $statement->queryString;
					$this->lastStatement = $statement;

					if (! $result) {
						throw new DatabaseException(implode(': ', $statement->errorInfo()) . PHP_EOL . PHP_EOL . $query);
					}

				} catch (PDOException $e) {
					throw new DatabaseException($e->getMessage() . PHP_EOL . PHP_EOL . $query);
				}

				$databaseResult = $this->createResult($statement, $entity);

				if ($query instanceof DatabaseQuery && $databaseResult instanceof DatabaseResult) {
					$this->cache->cacheQuery($query, $databaseResult);
				}

				if ($query instanceof DatabaseQuery) {
					$this->cache->refreshCache($query);
				}

				if ($databaseResult instanceof DatabaseResult) {
					return $databaseResult;

				} else if ($query instanceof DatabaseQuery && $query->getType() == DatabaseQuery::QUERY_TYPE_INSERT) {
					return $this->insertId($query->getTable());

				} else {
					return $databaseResult;
				}
			}
		}
789903
private function api_request( $_action ) {

		$geot_api_request_transient = $this->get_cached_version_info( $this->cache_key );

		if ( ! empty( $geot_api_request_transient ) ) {
			return $geot_api_request_transient;
		}

		$api_params = array(
			'slug' => $this->slug,
		);
		$url        = add_query_arg( $api_params, $this->api_url . $_action );

		$request = wp_remote_get( $url, array( 'timeout' => 15 ) );

		if ( is_wp_error( $request ) || isset( $request->error ) ) {
			return;
		}
		$request = json_decode( wp_remote_retrieve_body( $request ) );

		$data = $this->parseRequest( $request );
		$this->set_version_info_cache( $data );

		return $data;
	}
512483
protected function _executeQuery(Query $query, array $options = [])
    {
        switch ($query->action()) {
            case Query::ACTION_CREATE:
                return $this->_executeCreateQuery($query, $options);
            case Query::ACTION_READ:
                return $this->_executeReadQuery($query, $options);
            case Query::ACTION_UPDATE:
                return $this->_executeUpdateQuery($query, $options);
            case Query::ACTION_DELETE:
                return $this->_executeDeleteQuery($query, $options);
        }

        return false;
    }
130275
protected function _buildQuery(Query $query, $field, $value, array $data = [])
    {
        $type = $this->config('type');
        $value = '%' . $value . '%';
        $fields = $this->config('fields');
        $typesMap = $this->config('fieldTypes');
        $types = [];
        foreach ($fields as $field) {
            if (is_array($typesMap) && array_key_exists($field, $typesMap)) {
                $types[$field] = $typesMap[$field];
            } else {
                $types[$field] = null;
            }
        }
        if (empty($type)) {
            $type = 'and';
        }

        return $query->where(function ($exp) use (&$query, $value, $type, $fields, $types) {
            return $exp->{$type . '_'}(function ($ex) use ($value, $fields, $types) {
                collection($fields)->each(function ($field) use ($value, &$ex, $types) {
                    return $ex->like($field, $value, $types[$field]);
                });

                return $ex;
            });
        });
    }
659645
public function query($query, ...$data)
    {
        if ($data) {
            $query = $this->merge($query, $data);
        }

        try {
            $statement = $this->pdo->query($query);

            return new Result($statement);
        } catch (PDOException $exception) {
            throw new QueryException($exception, $query);
        }
    }
155053
public function search($query, array $data)
    {
        $sql = 'SELECT si.entity_id';

        if (!empty($data['count'])) {
            $sql = 'SELECT COUNT(si.entity_id)';
        }

        $conditions = array($query, $data['language'], 'und', 'product');

        $sql .= ' FROM search_index si
                  LEFT JOIN product p ON(p.product_id = si.entity_id)
                  WHERE MATCH(si.text) AGAINST (? IN BOOLEAN MODE)
                  AND (si.language=? OR si.language=?)
                  AND si.entity=? AND p.product_id IS NOT NULL';

        if (isset($data['status'])) {
            $sql .= ' AND p.status=?';
            $conditions[] = (int) $data['status'];
        }

        if (isset($data['store_id'])) {
            $sql .= ' AND p.store_id=?';
            $conditions[] = (int) $data['store_id'];
        }

        if (empty($data['count'])) {
            $sql .= ' GROUP BY si.entity_id';
        }

        if (!empty($data['limit'])) {
            $sql .= ' LIMIT ' . implode(',', array_map('intval', $data['limit']));
        }

        if (!empty($data['count'])) {
            return $this->config->getDb()->fetchColumn($sql, $conditions);
        }

        $data['product_id'] = $this->config->getDb()->fetchColumnAll($sql, $conditions);

        if (empty($data['product_id'])) {
            return array();
        }

        unset($data['language']);
        return $this->product->getList($data);
    }
1237346
public function display($actionName, array $data = null)
    {
        return parent::display($actionName, array_merge($this->commonVars(), $data));
    }
1340205
public function getEmptyForm(
        Action $action,
        Request $request,
        DataInterface $data
    ): FormInterface {
        $formOptions = $this->getDefaultFormOptions($action, $request, $data);
        unset($formOptions['family'], $formOptions['fieldset_options']);

        return $this->formFactory->createNamedBuilder(
            "form_{$action->getAdmin()->getCode()}_{$action->getCode()}",
            FormType::class,
            null,
            $formOptions
        )->getForm();
    }
4138
private static function routeAction()
    {
        $actionQueryString = Request::getInputValue("do", false, true);
        $actionQuery = Actions::parseActionQueryString($actionQueryString);
        
        Addons::executeComponentFunction($actionQuery->name, $actionQuery->method, @$actionQuery->arguments);
    }
266540
protected function request($action, array $data, $async = false)
    {
        $method = $async ? 'postAsync' : 'post';
        $payload = json_encode($data);

        $response = $this->httpClient->$method($action, [
            'json' => $data,
            'headers' => [
                'X-ICObench-Key' => $this->publicKey,
                'X-ICObench-Sig' => $this->sign($payload)
            ]
        ]);

        if($async){
            return $response->then(
                function (ResponseInterface $res) {
                    return $this->processResponse($res);
                }
            );
        }

        return $this->processResponse($response);
    }
658432
protected function httpRequestCurl($action, array $data, $method = 'POST', $options = [ ]) {
        $url = $this->api_uri . "/" . $action;
        $ch = curl_init();
        $options = array_merge($this->options, $options);
        if ($method == 'POST') {
            curl_setopt($ch, CURLOPT_POST, true);
            if ($this->fileUpload === true) {
                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                $this->fileUpload = false;
            } else {
                curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&'));
            }
        } else {
            $url .= '?' . http_build_query($data, '', '&');
            if ($method != 'GET') {
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
            }
        }
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
        curl_setopt($ch, CURLOPT_TIMEOUT_MS, $options['timeout']);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $options['connect_timeout']);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_HTTPHEADER, $this->httpHeaders);
        $response = curl_exec($ch);
        $this->lastResponseInfo = curl_getinfo($ch);
        curl_close($ch);

        if (!$response) {
            throw new Sailthru_Client_Exception(
                "Bad response received from $url",
                Sailthru_Client_Exception::CODE_RESPONSE_EMPTY
            );
        }

        // parse headers and body
        $parts = explode("\r\n\r\nHTTP/", $response);
        $parts = (count($parts) > 1 ? 'HTTP/' : '') . array_pop($parts); // deal with HTTP/1.1 100 Continue before other headers
        list($headers, $body) = explode("\r\n\r\n", $parts, 2);
        $this->lastRateLimitInfo[$action][$method] = self::parseRateLimitHeaders($headers);

        return $body;
    }
16965
public function findOne($query, array $data = null) {       
        $stmt = $this->executeQuery($query, $data);   
        
        return $stmt->fetch(\PDO::FETCH_ASSOC);
    }
95137
function plugins_api_filter( $data, $action = '', $args = null ) {
            $this->_logger->entrance();

            if ( ( 'plugin_information' !== $action ) ||
                 ! isset( $args->slug )
            ) {
                return $data;
            }

            $addon    = false;
            $is_addon = false;

            if ( $this->_fs->get_slug() !== $args->slug ) {
                $addon = $this->_fs->get_addon_by_slug( $args->slug );

                if ( ! is_object( $addon ) ) {
                    return $data;
                }

                $is_addon = true;
            }

            $plugin_in_repo = false;
            if ( ! $is_addon ) {
                // Try to fetch info from .org repository.
                $data = self::_fetch_plugin_info_from_repository( $action, $args );

                $plugin_in_repo = ( false !== $data );
            }

            if ( ! $plugin_in_repo ) {
                $data = $args;

                // Fetch as much as possible info from local files.
                $plugin_local_data = $this->_fs->get_plugin_data();
                $data->name        = $plugin_local_data['Name'];
                $data->author      = $plugin_local_data['Author'];
                $data->sections    = array(
                    'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.',
                );

                // @todo Store extra plugin info on Freemius or parse readme.txt markup.
                /*$info = $this->_fs->get_api_site_scope()->call('/information.json');

if ( !isset($info->error) ) {
    $data = $info;
}*/
            }

            $plugin_version = $this->_fs->get_plugin_version();

            // Get plugin's newest update.
            $new_version = $this->get_latest_download_details( $is_addon ? $addon->id : false, $plugin_version );

            if ( ! is_object( $new_version ) || empty( $new_version->version ) ) {
                $data->version = $plugin_version;
            } else {
                if ( $is_addon ) {
                    $data->name    = $addon->title . ' ' . $this->_fs->get_text_inline( 'Add-On', 'addon' );
                    $data->slug    = $addon->slug;
                    $data->url     = WP_FS__ADDRESS;
                    $data->package = $new_version->url;
                }

                if ( ! $plugin_in_repo ) {
                    $data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created;
                    $data->requires     = $new_version->requires_platform_version;
                    $data->tested       = $new_version->tested_up_to_version;
                }

                $data->version       = $new_version->version;
                $data->download_link = $new_version->url;

                if ( isset( $new_version->readme ) && is_object( $new_version->readme ) ) {
                    $new_version_readme_data = $new_version->readme;
                    if ( isset( $new_version_readme_data->sections ) ) {
                        $new_version_readme_data->sections = (array) $new_version_readme_data->sections;
                    } else {
                        $new_version_readme_data->sections = array();
                    }

                    if ( isset( $data->sections ) ) {
                        if ( isset( $data->sections['screenshots'] ) ) {
                            $new_version_readme_data->sections['screenshots'] = $data->sections['screenshots'];
                        }

                        if ( isset( $data->sections['reviews'] ) ) {
                            $new_version_readme_data->sections['reviews'] = $data->sections['reviews'];
                        }
                    }

                    if ( isset( $new_version_readme_data->banners ) ) {
                        $new_version_readme_data->banners = (array) $new_version_readme_data->banners;
                    } else if ( isset( $data->banners ) ) {
                        $new_version_readme_data->banners = $data->banners;
                    }

                    $wp_org_sections = array(
                        'author',
                        'author_profile',
                        'rating',
                        'ratings',
                        'num_ratings',
                        'support_threads',
                        'support_threads_resolved',
                        'active_installs',
                        'added',
                        'homepage'
                    );

                    foreach ( $wp_org_sections as $wp_org_section ) {
                        if ( isset( $data->{$wp_org_section} ) ) {
                            $new_version_readme_data->{$wp_org_section} = $data->{$wp_org_section};
                        }
                    }

                    $data = $new_version_readme_data;
                }
            }

            return $data;
        }