laravel - 从 SQL 表中调用特定值
问题描述
寻求您的帮助我有一个基于 laravel 的网站,我需要对页面提供多语言支持我有以下代码来查看页面:
@extends('web.layout')
@section('content')
<section class="aboutus-content aboutus-content-one">
<div class="container">
<div class="heading">
<h2>
<?=$result['pages'][0]->name?>
</h2>
<hr style="margin-bottom: 10;">
</div>`
<?=stripslashes($result['pages'][0]->description)?>
</div>
</section>
@endsection
调用函数
$result['pages'] = DB::table('pages')
->leftJoin('pages_description', 'pages_description.page_id', '=', 'pages.page_id')
->where([['type','2'],['status','1'],['pages_description.language_id',session('language_id')]])
->orwhere([['type','2'],['status','1'],['pages_description.language_id',session('language_id')]])->orderBy('pages_description.name', 'ASC')->get();
数据库是这样的:https ://prnt.sc/rpn9ye
问题是当我切换页面语言时,它不会抓取阿拉伯语,尽管它在数据库中有正确的输入,但它只对我坚持英语。
先感谢您
解决方案
现在已经解决了
public function getPages($request) { $pages = DB::table('pages') ->leftJoin('pages_description', 'pages_description.page_id', '=', 'pages.page_id') ->where([[ 'pages.status', '1'], ['type', 2], ['pages_description.language_id', session('language_id')], ['pages.slug', $request->name]]) - >orwhere([['pages.status', '1'], ['type', 2], ['pages_description.language_id', session('language_id')], ['pages.slug', $request->名称]]) ->get(); 返回 $pages; }
我已经用直接会话ID替换了一个在orwhere并且它起作用了。
推荐阅读
- linux - 带有 RT Linux(RT-PREEMPT 补丁)的 ZeroMQ 是实时的吗?
- javascript - jqGrid没有在ajax发布请求上重新加载/刷新
- javascript - 弹性 APM RUM 缺少嵌套跨度
- node.js - 如何使用 Firebase 身份验证通过 NodeJS 后端进行 Android 应用身份验证
- python - matplotlib 从二维数组直接映射到图像 RGB 数据
- postman - Postman - 如何替换 JSON 响应中所有特定属性的值,以便稍后将其用作另一个请求的正文
- tinymce - 活动编辑器中的可点击链接
- c# - 有没有一种简单的方法可以让 WinForms 应用程序中的所有文本框响应某些键盘快捷键?
- java - 在单元测试中的 Java 中,使用 Mockito,如何模拟对 XML DocumentBuilder 的调用,使其不返回 FileNotFoundException
- postgresql - 运行查询时出现语法错误:“在“\”或附近出现语法错误”