第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

無(wú)法訪問(wèn)字符串變量(“1”)上的屬性(“名稱”)

無(wú)法訪問(wèn)字符串變量(“1”)上的屬性(“名稱”)

PHP
胡子哥哥 2022-01-08 17:29:18
我怎樣才能得到名字而不僅僅是id?這實(shí)際上是我在數(shù)據(jù)表 中的內(nèi)容:當(dāng)前數(shù)據(jù)表但我需要的是顯示區(qū)域的名稱而不是 id。我試圖這樣做:<table aria-describedby="dataTable_info" cellspacing="0" class="table table-hover dataTable" id="dataTable" role="grid" style="width:100%;" width="100%">                        <thead>                            <tr>                                <th>Areas</th>                                <th>Auditorias</th>                            </tr>                        </thead>                        <tbody>                            {% for audit in auditsByArea %}                                    <tr>                                        <td>{{ audit.id_Area.name }}</td>                                        <td>{{ audit.Audits }} <input style="width:0.8cm; height:0.8cm;background-color:##E4E8E9; border-radius: 8px; border-color:#3A93B2"  class ="mx-2" data-id="4" data-area="{{ audit.id_Area }}"data-responsible="4" data-startDate="<?php date('n/d/Y');?>" id="auditBtn" name="auditBtn" type='text' readonly  data-toggle="modal" data-target="#auditModal"></input></td>                                    </tr>                             {% endfor %}                        </tbody>                    </table>但我收到以下錯(cuò)誤:無(wú)法訪問(wèn)字符串變量(“1”)上的屬性(“名稱”)。關(guān)于修復(fù)它的任何想法或建議?或者有什么問(wèn)題?這是我在轉(zhuǎn)儲(chǔ) AuditsByArea 時(shí)得到的:    array (size=3)  0 =>     array (size=2)      'id_Area' => string '1' (length=1)      'Audits' => string '1,2,3,4' (length=7)  1 =>     array (size=2)      'id_Area' => string '3' (length=1)      'Audits' => string '12,11,10,9' (length=10)  2 =>     array (size=2)      'id_Area' => string '5' (length=1)      'Audits' => string '17,18,19,20' (length=11)
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊

在您寫的評(píng)論中,您的查詢是:


SELECT id_Area, GROUP_CONCAT(id_Audit) as Audits 

FROM helios.fsa_audits 

WHERE id_Auditor='$AuditorId' 

GROUP BY id_Area;

添加要輸出的信息:


SELECT id_Area, area.Name as area_name, GROUP_CONCAT(id_Audit) as Audits 

FROM helios.fsa_audits 

LEFT JOIN helios.fas_areas area USING (id_Area)

WHERE id_Auditor='$AuditorId' 

GROUP BY id_Area;

您可以通過(guò)以下方式在循環(huán)中訪問(wèn)它:


{{ audit.area_name }}

但是請(qǐng)注意,您使用的是普通的 php 數(shù)組,帶有“手動(dòng)”sql 查詢,并且沒(méi)有教義的 ORM 提供的任何功能。


查看完整回答
反對(duì) 回復(fù) 2022-01-08
  • 1 回答
  • 0 關(guān)注
  • 151 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)