$run = $dbh->prepare($query);
echo $query;
//if($run->execute()) {
if($run->rowCount() > 0) {
$result = $run->fetchAll(PDO::FETCH_ASSOC);
$i = 0;
while($i < count($result)) {
for($e=0; $e < count($result); $e++) {
$result[$e] = str_replace('Ñ','Ñ', str_replace('ñ','ñ', $result[$e]));
$i++;
}
}
return $result;
} else {
return array('error'=> TRUE, 'message'=> 'No result found.','query'=> $query);
}
//}
我有这个查询,查询中的echo是:
CALL `select_date`('2016-01-01', '2016-01-31')
select_date
的位置:
CREATE DEFINER=`root`@`localhost` PROCEDURE `select_date`(
param1 varchar(64),
param2 varchar(64)
)
BEGIN
declare v_max int default 0;
declare v_counter int default 0;
start transaction;
set v_max = (SELECT COUNT(*)
FROM transaction_detail4
WHERE
transaction_date >= param1 AND
transaction_date <= param2);
while v_counter < v_max do
# random query
SELECT *
FROM transaction_detail4
WHERE
transaction_date >= param1 AND
transaction_date <= param2 GROUP BY transaction_id LIMIT v_counter , 1000;
set v_counter = v_counter + 1000;
end while;
commit;
END
我假设它将循环并返回循环中的所有数据但它只给我1000
意味着只获得第一次迭代。因为select应返回49k +记录。
如何从循环选择
返回所有数据