我正在嘗試將數(shù)據(jù)表作為服務器端處理。它以某種方式起作用。我想將字段傳遞給 ajax 文件并使用它們來獲取數(shù)據(jù)。我將字段名稱設為字符串以使用分隔符分隔它們。然后我傳遞了字符串并獲取它并將它們作為一個數(shù)組。問題是,當我嘗試通過它們獲取值時會顯示“數(shù)組到字符串轉換錯誤”。十月 CMS 中的 PHP 塊<?phpfunction onStart(){ $this['tableName'] = 'BYAPPS_apps_data'; $this['fields'] = "app_id|app_name|app_ver|byapps_ver";}?>10 月 CMS 中的 Javascript(與 php 塊相同的頁面) var table = $('#' + tableId).DataTable( { processing: true, serverSide: true, ajax: { url: '/ajax?tb={{ tableName|raw() }}&fd={{ fields|raw() }}', type: 'GET', error: function(e) { console.log(e); } }, paging: true, pageLength: 50,Ajax 頁面function onStart(){ $table = $_GET['tb']; $length = $_GET['length']; $start = $_GET['start']; $fields = explode("|", $_GET['fd']); $result = DB::table($table)->skip($start)->limit($length)->get(); $data = array(); foreach($result as $row) { $sub_array = array(); for ($i = 0; $i < count($fields); $i++) { echo "<script>console.log('".$fields[$i]."')</script>"; $sub_array[] = $row->$fields[$i]; } $data[] = $sub_array; }該$fields[$i]節(jié)目“APP_ID”,“APP_NAME” ...但我不知道為什么我不能通過這樣得到的數(shù)值。$row->$fields[$i] 我該如何解決這個問題?$result 包含這些類似下面的數(shù)據(jù)。object(October\Rain\Support\Collection)#947 (1) { ["items":protected]=> array(50) { [0]=> object(stdClass)#949 (88) { ["idx"]=> int(1) ["o_idx"]=> int(0) ["mem_id"]=> string(20) "epicegirls@naver.com" ["app_id"]=> string(10) "epicegirls" ["recom_id"]=> string(6) "byapps" ["app_cate"]=> string(2) "01" ["app_process"]=> int(8) ["app_name"]=> string(12) "????" ["service_type"]=> string(3) "biz" ["server_group"]=> string(1) "2" ["apps_type"]=> string(19) "?
嘗試獲取字段值時出現(xiàn)“數(shù)組到字符串轉換錯誤”
不負相思意
2021-08-20 19:31:10