php - 如何从数据库中返回属性
问题描述
我有问题。看看我的功能。向你详细解释一切。第一个仅返回“前”或“后”,具体取决于选择了哪一个。我希望如果没有选择这些,请以这种格式将所有内容从正面和背面返回给我:
array (size=3)
'breite' => string '110' (length=3)
'hoehe' => string '70' (length=2)
'zoll' => string '17' (length=2)
看我的网址:
http://localhost/ccr/filter?atts[breite]=110&atts[hoehe]=70&atts[zoll]=17&parent=49
通过 url 我发送 attibutes 正面或背面。
我只需要通过 url ,如果正面或背面未选择返回和正面和背面。看看我需要的功能代码:
if(key_exists('antrieb',$get)) {
$antrieb = $get['antrieb']; //back or front
$query = $this->db->query("
SELECT mo.$antrieb
FROM " . DB_PREFIX . "model mo
WHERE mo.id != 0
$where
")->rows;
$data = [];
$size = explode("|", $query[0][$antrieb]);
$data['atts'] = array(
'breite' => $size[0],
'hoehe' => $size[1],
'zoll' => $size[2]
);
}else {
$query = $this->db->query("
SELECT mo.front, mo.back
FROM " . DB_PREFIX . "model mo
WHERE mo.id != 0
$where
")->rows;
var_dump($query);
(result this code is comment only for show you
array (size=2)
'front' => string '110|70|17' (length=9)
'back' => string '130|70|17' (length=9)
)
$size = explode("|", $query[0]);
there is litle problem i need expolde front and back with |
$data2 = [];
$data2['atts'] = [
'breite' => $size[0],
'hoehe' => $size[1],
'zoll' => $size[2]
];
(resulte write only for you
var_dump($data2);
array (size=1)
'atts' =>
array (size=3)
'breite' => null
'hoehe' => null
'zoll' => null
}
)
看看我需要得到的专栏: https ://imgur.com/YK9wNRy
这只是拥有超过 150 行代码的功能的一部分。我认为问题就在这里,这就是为什么我告诉你我不会把所有的东西都写得太大而你不会明白。如果你有问题在这里。如果你想要我向你展示的所有功能。前面是 react.js,但现在这并不重要。谢谢
解决方案
推荐阅读
- ios - 如何在不打开父应用程序的情况下使用 SwiftUI for Widget 添加点击事件和更新视图?
- python - 如何使用 Pyspark 根据条件从另一个表更新表的 Spark DataFrame 列值
- android - 谷歌应用操作审核流程的时间长度是多少?
- http - 上传视频的大小在服务器上为 0,即使视频有大小
- laravel - 是否有任何使用 Office 365 邮件发送邮件的 Laravel 软件包?
- javascript - 我应该使用什么来根据过滤器选择获取更新的计数?
- java - 用于数据库迁移的 MongoDB 'mongock'
- python - 在Python中获取参数中文件的目录路径
- matlab - Matlab 使用 parfor 时崩溃
- asp.net-core - dotnet-monitor 和 OpenTelemetry?