如何从 PHP 获取值到 ExtJs?

How to get a value from PHP to ExtJs?

如何从 PHP 函数获取值到我的 ext js 后端?

是否可以通过这样的Ajax请求来解决这个问题?

Ext.Ajax.request({
url: '{url action=getSqlDetails}',
params: {
count:count
},

在这种情况下,我需要 $count 变量。

public function getSqlDetailsAction() {
$fileName = $this->Request()->getParam('fileName');
$start = $this->Request()->getParam('start');
$limit = $this->Request()->getParam('limit');

$pluginFolder = dirname(dirname(__DIR__));
$sqlFolder = $pluginFolder . '/SqlFiles/';
$filePath = $sqlFolder . $fileName;
$sql = file_get_contents($filePath);
$count = substr_count($sql, '?');
if ($count > 0) {
    $this->View()->count = $count;
    //  Shopware()->Db()->query($sql, array(' EXT js fields from Filter Panel'));
} else {
    $sqlResultList = Shopware()->Db()->query($sql . " limit " . $start . ", " . $limit);
    $this->View()->success = true;
    $this->View()->data = $sqlResultList->fetchAll();
    $this->View()->total = Shopware()->Db()->query("select count(*) from ($sql) result")->fetchColumn();
}
}

访问Sencha Web Page了解更多信息

Ext.Ajax.request({
    url: '{url action=getSqlDetails}',
    params: {
        count:count
    },
    // http success : code 200
    success: function(response){
        console.log(response.responseText);
    }
});