[英]Create and compare array for results
Learning curve question. 学习曲线问题。 I have searched and the answers elude me.
我已经搜索过了,答案却无法确定。 How can I take a basic result such as $row->product_id which returns a total of $limit items and turn it into an array that can then be used in another query to get more results.
如何获取基本结果(例如$ row-> product_id),该结果将返回总计$ limit个项目,并将其转换为一个数组,然后可以在另一个查询中使用该数组以获取更多结果。
$db->setQuery( $query );
$rows = $db->loadObjectList();
foreach($rows as $row){
echo '<div>' . $row->product_id . '</a></div>';
}
This gets me the results to echo but I need to use them again in another query. 这使我得到要回显的结果,但是我需要在另一个查询中再次使用它们。
$query="select my_colum from my_table where myItem_Array_results LIMIT
Please help. 请帮忙。
What exactly are you trying to achieve? 您到底想达到什么目的? Do you want to use results of a
SELECT
in another query? 是否要在另一个查询中使用
SELECT
结果?
Than you should do the whole operation in MySQL. 比您应该在MySQL中完成整个操作。 Read about JOINs .
了解有关JOIN的信息 。 Not only is it more clear and logical, but also much faster.
它不仅更加清晰和合乎逻辑,而且速度更快。
SELECT `id`, `name` FROM `products` LEFT JOIN `my_table` ON `my_table`.`my_column` = `products`.`id`
My php is rusty but try something like this: 我的php生锈了,但是尝试这样的事情:
$db->setQuery( $query );
$product_ids = array();
$rows = $db->loadObjectList();
foreach($rows as $row){
$product_ids[] = $row->product_id;
echo '<div>' . $row->product_id . '</a></div>';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.