Database 控制器中Laravel查询的特殊字符问题(尝试了多种解决方法)
我一直试图从我的数据库中检索数据。在我开始查询带有特殊字符的单词(我说葡萄牙语,所以我们使用了很多口音)之前,它工作得很好。在我的控制器中,我有:Database 控制器中Laravel查询的特殊字符问题(尝试了多种解决方法),database,laravel,Database,Laravel,我一直试图从我的数据库中检索数据。在我开始查询带有特殊字符的单词(我说葡萄牙语,所以我们使用了很多口音)之前,它工作得很好。在我的控制器中,我有: public function showall() { $horarios = Horario::All(); $professores = array(); foreach($horarios as $horario) { $professor_primeiro_nome[$horario - &
public function showall() {
$horarios = Horario::All();
$professores = array();
foreach($horarios as $horario) {
$professor_primeiro_nome[$horario - > id] = DB::table('professors') - > where('id', '=', $horario - > professor_id) - > pluck('primeiro_nome');
$professor_primeiro_nome[$horario - > id] =
trim($professor_primeiro_nome[$horario - > id], '[""]');
$professor_ultimo_nome[$horario - > id] = DB::table('professors') - > where('id', '=', $horario - > professor_id) - > pluck('ultimo_nome');
$professor_ultimo_nome[$horario - > id] =
trim($professor_ultimo_nome[$horario - > id], '[""]');
$materias[$horario - > id] = (string) DB::table('materias') - > where('id', '=', $horario - > materia_id) - > pluck('materia');
$materias[$horario - > id] = trim($materias[$horario - > id], '[""]');
}
return View::make('veraulas',
compact('horarios', 'professor_primeiro_nome',
'professor_ultimo_nome', 'materias'));
}
我认为:
<!-- Table Headings -->
<thead>
<tr>
<th>Professor</th>
<th>Matéria</th>
<th>Data</th>
<th>Início</th>
<th>Fim</th>
<th>Ver Detalhes da Aula</th>
<th>Editar Aula</th>
<th>Remover Aula</th>
</tr>
</thead>
<!-- Table Body -->
<tbody>
@foreach ($horarios as $horario)
<tr>
<!-- Task Name -->
<td>
<div>{{ $professor_primeiro_nome[$horario->id] }} {{ $professor_ultimo_nome[$horario->id] }}</div>
</td>
<td>
<div>{{ $materias[$horario->id]) }}</div>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<form>
{{ csrf_field() }}
<button>Ver Detalhes</button>
</form>
</td>
<td>
<form>
{{ csrf_field() }}
<button>Editar</button>
</form>
</td>
<td>
<form>
{{ csrf_field() }} {{ method_field('DELETE') }}
<button>Remover</button>
</form>
</td>
</tr>
@endforeach
</tbody>
教授
马蒂利亚
资料
伊尼西奥
职能指令手册
奥拉大道
伊迪塔奥拉
奥拉拆卸器
@foreach($horarios作为$horario)
{{$professor\u primeiro\u nome[$horario->id]}{{$professor\u ultimo\u nome[$horario->id]}
{{$materialas[$horario->id])}
{{csrf_field()}}
详细说明
{{csrf_field()}}
编辑
{{csrf_field()}{{method_field('DELETE')}
搬运工
@endforeach
页面如下所示:
这些单词有奇怪的字符…我能做些什么来解决这个问题?其他单词看起来不错。当我查询数据库并将结果传递给数组时会出现问题。这些符号是否正确存储在数据库中?正确的排序?是的。有趣的是,从数据库检索到的所有其他数据都是正确的。当我使用Pull并将数据传递给数组时,单词变成这样。只有
Pull
方法?如果使用get
进行检索,数据是否正确?我已解决!我认为传递给数组是在改变编码。我做了一个原始的选择,它的工作$horarios=DB::select(DB::raw(“选择horarios h的p.primeiro_nome,p.ultimo_nome,m.Materiala,h.data,h.inicio,h.fim,教授p,材料m,其中h.professor_id=p.id,h.Materiala_id=m.id”);