我找不到解决该问题的方法
var_dump($orders_status_support_array[$value['orders_status_support_id']]);
始终返回相同的值
谢谢。
$QordersHistory = $this->app->db->prepare('select orders_status_support_id,
orders_status_history_id
from :table_orders_status_history
where orders_id = :orders_id
order by date_added desc
');
$QordersHistory->bindInt(':orders_id',$oID);
$QordersHistory->execute();
$order_array = $QordersHistory->fetchAll();
foreach ($order_array as $value)
{
$QordersStatusSupport = $this->app->db->prepare('select orders_status_support_id,
orders_status_support_name
from :table_orders_status_support
where language_id = :language_id
and orders_status_support_id = :orders_status_support_id
');
$QordersStatusSupport->bindInt(':language_id', $CLICSHOPPING_Language->getId());
$QordersStatusSupport->bindInt(':orders_status_support_id', $value['orders_status_support_id']);
$QordersStatusSupport->execute();
$orders_status_support_array[$value['orders_status_support_id']] = $QordersStatusSupport->value('orders_status_support_name');
}
结果: var_dump(orders_status_support_array)
array(3) { [2]=> string(7) "Pending" [4]=> string(8) "Resolved" [3]=> string(7) "Process" } array(3) { [2]=> string(7) "Pending" [4]=> string(8) "Resolved" [3]=> string(7) "Process" } array(3) { [2]=> string(7) "Pending" [4]=> string(8) "Resolved" [3]=> string(7) "Process"
结果: var_dump($orders_status_support_array[$value['orders_status_support_id']]);
string(7) "Process" string(7) "Process" string(7) "Process"
var_dump($ value)
array(2) { ["orders_status_support_id"]=> string(1) "2" ["orders_status_history_id"]=> string(2) "15" } array(2) { ["orders_status_support_id"]=> string(1) "4" ["orders_status_history_id"]=> string(2) "14" } array(2) { ["orders_status_support_id"]=> string(1) "3" ["orders_status_history_id"]=> string(2) "13" } string(7) "Process" array(2) { ["orders_status_support_id"]=> string(1) "2" ["orders_status_history_id"]=> string(2) "15" } array(2) { ["orders_status_support_id"]=> string(1) "4" ["orders_status_history_id"]=> string(2) "14" } array(2) { ["orders_status_support_id"]=> string(1) "3" ["orders_status_history_id"]=> string(2) "13" } string(7) "Process" array(2) { ["orders_status_support_id"]=> string(1) "2" ["orders_status_history_id"]=> string(2) "15" } array(2) { ["orders_status_support_id"]=> string(1) "4" ["orders_status_history_id"]=> string(2) "14" } array(2) { ["orders_status_support_id"]=> string(1) "3" ["orders_status_history_id"]=> string(2) "13" } string(7) "Process"
答案 0 :(得分:0)
我认为您的问题可能是关键问题...
基本上,您正在寻找:
$orders_status_support_array[2]
2
是index
,而orders_status_support_id
中的$value
是2。
第三个元素,即2
中的索引[0,1,2]
$orders_status_support_array
为"Process"
,因此看起来它可能不尊重您的索引号,而是按顺序对其进行了处理
您是否可以通过在$orders_status_support_array
中包括所有状态而不是仅包括您所包括的3个来验证这一理论?
例如:
0 => "Other Status 1"
1 => "Other Status 2"
2 => "Pending"
3 => "Process"
4 => "Resolved"
当前,前两个元素似乎丢失了,而元素4
和3
是错误的方法。
整理数组,包括其他状态,使它们以正常的键顺序(例如0, 1, 2, 3, 4
等)存在,您应该会发现更容易实现此目的。
这有意义吗?