laravel DB facade를 사용하여 쿼리를 실행하고 json 배열 객체를 반환하지만 json 배열에서 단일 필드 값에 액세스하려고 할 때 오류가 발생합니다.json 배열에서 단일 필드 데이터를 인쇄하는 방법
내 검색어 부분은 다음과 같습니다.
$dsale=DB::table('directsales')
->join('clients','directsales.client_id','=','clients.id')
->join('products','directsales.product_id','=','products.id')
->select('clients.client_name','clients.addr','directsales.*','products.name')
->where('directsales.client_id','=',$client_id)
->whereBetween('directsales.issue_date',[$fromdate,$todate])
->distinct()
->get();
return $dsale;
이것은 내 결과입니다. 내가 클라이언트 _ $ dsale 인쇄 할 때
[{"client_name":"client one","addr":"jdkdhjfkhdkshfds","id":1,"transaction_code":"IN--00000001","client_id":1,"product_id":1,"product_code":"P0007","unitperctn":20,"unitprice":100,"ctn":4,"pcs":5,"total":4500,"deliverd_by":"nazim","issue_date":"2017-12-01","created_at":"2017-11-28 13:55:29","updated_at":"2017-11-28 13:55:33","name":"Dano Instant 2.5 Kg Packet 6"},{"client_name":"client one","addr":"jdkdhjfkhdkshfds","id":2,"transaction_code":"IN--00000002","client_id":1,"product_id":1,"product_code":"P0001","unitperctn":12,"unitprice":100,"ctn":1,"pcs":1,"total":2,"deliverd_by":"majed","issue_date":"2017-12-01","created_at":null,"updated_at":null,"name":"Dano Instant 2.5 Kg Packet 6"},{"client_name":"client one","addr":"jdkdhjfkhdkshfds","id":3,"transaction_code":"IN--00000002","client_id":1,"product_id":4,"product_code":"P0004","unitperctn":12,"unitprice":90,"ctn":1,"pcs":3,"total":6,"deliverd_by":"majed","issue_date":"2017-12-01","created_at":null,"updated_at":null,"name":"All time bread"},{"client_name":"client one","addr":"jdkdhjfkhdkshfds","id":5,"transaction_code":"IN--00000004","client_id":1,"product_id":1,"product_code":"P0001","unitperctn":12,"unitprice":100,"ctn":1,"pcs":0,"total":1,"deliverd_by":"majed","issue_date":"2017-12-12","created_at":null,"updated_at":null,"name":"Dano Instant 2.5 Kg Packet 6"},{"client_name":"client one","addr":"jdkdhjfkhdkshfds","id":6,"transaction_code":"IN--00000005","client_id":1,"product_id":4,"product_code":"P0004","unitperctn":12,"unitprice":90,"ctn":3,"pcs":3,"total":3510,"deliverd_by":"add","issue_date":"2017-12-03","created_at":null,"updated_at":null,"name":"All time bread"},{"client_name":"client one","addr":"jdkdhjfkhdkshfds","id":10,"transaction_code":"IN--00000007","client_id":1,"product_id":4,"product_code":"P0004","unitperctn":12,"unitprice":90,"ctn":1,"pcs":6,"total":1620,"deliverd_by":"majed","issue_date":"2017-11-01","created_at":null,"updated_at":null,"name":"All time bread"}]
은 -> [ '클라이언트 _'] [0]이 방법은 쇼 오류입니다. 배열의
시도 :'$의 dsale [0] [ '클라이언트 _']'- HTTPS : //3v4l.o rg/nCQuV –
은 json이 아니며 stdClass 객체의 컬렉션 또는 배열입니다. 'echo'할 때만 json이 표시됩니다. – lagbox