我正在尝试制作更简单的
版本$query1 = "SELECT $select FROM HelpDesk ORDER BY createdtime DESC LIMIT 100";
$records1 = $client->doQuery($query);
$query2 = "SELECT $select FROM HelpDesk ORDER BY createdtime DESC LIMIT 100,100";
$records2 = $client->doQuery($query2);
我要做的就是运行它,以便它像
$qnum = 1; qmax = 15; $offset = 100;
while (qnum < $qmax) {
$query# = "SELECT $select FROM Table ORDER BY Field DESC LIMIT 100,$offset";
$records# = $client->doQuery($query#);
}
$records = array_merge($records[]);
现在我知道这太可怕了,但我只是试图了解我正在尝试做的事情。
我对数组很新,而且我知道我需要一个for或foreach来进行偏移。我只是不确定该怎么做。
感谢Chococroc我现在使用的代码是:
$query1 = "SELECT $select FROM HelpDesk ORDER BY createdtime DESC LIMIT 100";
$records1 = $client->doQuery($query1);
$records = array();
for ($i = 100; $i <= 1500; $i+=100 ) {
$query = "SELECT $select FROM HelpDesk ORDER BY createdtime DESC LIMIT 100,$i";
$new_records = $client->doQuery($query);
$records = array_merge($records, $new_records);
}
$records = array_merge($records, $records1);
我确实把它原来设置为$ i = 0但它似乎跳过了一行或3(取决于刷新)。
答案 0 :(得分:0)
如果你现在在哪里开始,在哪里完成,只需使用for
循环:
$result = array();
for ($i = 100; $i <= 1500; $i+=100 ) {
$query = "SELECT $select FROM HelpDesk ORDER BY createdtime DESC LIMIT $i, 100";
$new_result = $client->doQuery($query);
$result = array_merge($result, $new_result);
}
请注意偏移量,它是限制中的第一个参数。