php - 从结果集中的每5条记录上调用一个函数

时间:2014-02-23 14:27:47

标签: php mysql wordpress paypal-adaptive-payments

我想使用自适应支付api,因为我知道我只能使用5或6条记录。 有没有办法自动化进程获取,例如6个记录调用结果上的函数 然后从6记录再次启动过程?

我不能使用任何php数据库类,因为我在wordpress插件中使用它。 仅供参考:https://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results

示例结果:

    Array
(
    [0] => Array
        (
            [seller_paypal1] => yehuda@site.com
            [commission1] => 16.5
        )

    [1] => Array
        (
            [seller_paypal2] => yehuda@site.com
            [commission2] => 16.5
        )

    [2] => Array
        (
            [seller_paypal3] => yehuda@site.com
            [commission3] => 16.5
        )

    [3] => Array
        (
            [seller_paypal4] => yehuda@site.com
            [commission4] => 16.5
        )

    [4] => Array
        (
            [seller_paypal5] => yehuda@site.com
            [commission5] => 16.5
        )

    [5] => Array
        (
            [seller_paypal6] => yehuda@site.com
            [commission6] => 16.5
        )
    [6] => Array
        (
            [seller_paypal7] => yehuda@site.com
            [commission7] => 16.5
        )

)


<?php
// just a fiction way for example
foreach ($records /5 as record) {
  start record 0-5
  adaptive($record['seller_paypal'], $record['commission']);
  //5 records finished start from the 6-11
}

function adaptive($seller_email,$commission) {
// stuff here
}

1 个答案:

答案 0 :(得分:0)

PDOStatement::fetchAll - 返回一个包含所有结果集行或您想要的数组