似乎这将是相当简单,然而,我遇到了一个问题:
代码如下:
function getValidCustomers() {
global $db;
$getCustomers = $db->GetAll("SELECT * from customers where CustomerActive='1' AND protected IS NULL or protected=0;");
foreach($getCustomers as $customer) {
echo $customer['CustomerID']."'n";
}
}
function updateValidCustomers() {
$customers = getValidCustomers();
for ($i = 0; $i < sizeof($customers); $i++) {
echo "DEBUG: $customers[$i]'n";
}
}
updateValidCustomers();
基本上,现在的输出是customerid的列表(来自updateValidCustomers()
)。我只想让updateValidCustomers()
从getValidCustomers()
获取数据,然后循环它,这样我就可以在它上运行另一个查询,这将实际操作数据库。
任何想法?
getValidCustomers
不返回任何东西,也许你的意思是:
function getValidCustomers() {
global $db;
$getCustomers = $db->GetAll("SELECT * from customers where CustomerActive='1' AND protected IS NULL or protected=0;");
foreach($getCustomers as $customer) {
echo $customer['CustomerID']."'n";
}
return $getCustomers;
}
getValidCustomers()
不返回任何东西-它只是回显
将return $getCustomers
添加到getValidCustomers()
的末尾
添加return $getCustomers;
到getValidCustomers()
:D