3

私は現在ezSQLを使用しています。これは、優れたSQLラッパーであると信じています。ただ立ち寄ることができるページネーションを追加するという任務を負っています。Zendには1つありますが、Zendの他の部分と緩く結合されているため、機能するはずです。ezSQL、alaを使用して配列を返します。

$results = $db->get_results("SELECT * FROM table", ARRAY_A);

次に、これをページネーターにシフトします。

$paginator = Zend_Paginator::factory($results);

の場合var_dump($paginator)、クエリからリストされた値が表示されます。しかし、私がそうすればecho $paginator->pageCount)、私は得NULLます。どうしたんだ?

残念ながら、ezSQLからZend_DBへの切り替えは、私たちのグループにとって本質的に不可能であるため、それは問題外です。

編集:出力元print_r($paginator)

Zend_Paginator Object
(
    [_cacheEnabled:protected] => 1
    [_adapter:protected] => Zend_Paginator_Adapter_Array Object
        (
            [_array:protected] => Array
                (
                    [0] => Array
                        (
                            [first_name] => Doug
                            [last_name] => Lawrence
                            [avatar] => Doug_Lawrence.png
                            [updated_by] => 14306
                            [id] => 413
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-29 12:57:52
                            [publish_date] => 10/29/09
                        )

                    [1] => Array
                        (
                            [first_name] => Jason
                            [last_name] => Lewis
                            [avatar] => Jason.Lewis.jpg
                            [updated_by] => 13547
                            [id] => 411
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-25 09:19:48
                            [publish_date] => 10/25/09
                        )

                    [2] => Array
                        (
                            [first_name] => David
                            [last_name] => Bowman
                            [avatar] => David_Bowman.png
                            [updated_by] => 13564
                            [id] => 409
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-24 15:13:13
                            [publish_date] => 10/24/09
                        )

                    [3] => Array
                        (
                            [first_name] => David
                            [last_name] => Bowman
                            [avatar] => David_Bowman.png
                            [updated_by] => 13564
                            [id] => 410
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-24 15:15:48
                            [publish_date] => 10/24/09
                        )

                    [4] => Array
                        (
                            [first_name] => Greg
                            [last_name] => Morris
                            [avatar] => GKMorris.png
                            [updated_by] => 13555
                            [id] => 408
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-24 10:21:14
                            [publish_date] => 10/24/09
                        )

                    [5] => Array
                        (
                            [first_name] => Thom
                            [last_name] => Rainer
                            [avatar] => Thom_Rainer.jpg
                            [updated_by] => 13560
                            [id] => 405
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-23 06:53:43
                            [publish_date] => 10/23/09
                        )

                    [6] => Array
                        (
                            [first_name] => David
                            [last_name] => Bowman
                            [avatar] => David_Bowman.png
                            [updated_by] => 13564
                            [id] => 406
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-23 16:20:33
                            [publish_date] => 10/23/09
                        )

                    [7] => Array
                        (
                            [first_name] => Tom
                            [last_name] => Harper
                            [avatar] => 1225910432_63
                            [updated_by] => 10843
                            [id] => 402
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-22 11:17:16
                            [publish_date] => 10/22/09
                        )

                    [8] => Array
                        (
                            [first_name] => Jerome
                            [last_name] => Daley
                            [avatar] => Jerome_Daley.png
                            [updated_by] => 13554
                            [id] => 403
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-22 14:06:31
                            [publish_date] => 10/22/09
                        )

                    [9] => Array
                        (
                            [first_name] => Mark
                            [last_name] => Howell
                            [avatar] => Mark_Best.png
                            [updated_by] => 13561
                            [id] => 404
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-22 21:44:51
                            [publish_date] => 10/22/09
                        )

                    [10] => Array
                        (
                            [first_name] => Margaret
                            [last_name] => Marcuson
                            [avatar] => Marcuson.png
                            [updated_by] => 14398
                            [id] => 401
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-21 18:21:55
                            [publish_date] => 10/21/09
                        )

                    [11] => Array
                        (
                            [first_name] => Barry
                            [last_name] => Winders
                            [avatar] => Barry_Winders.png
                            [updated_by] => 13552
                            [id] => 400
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-20 20:08:36
                            [publish_date] => 10/20/09
                        )

                    [12] => Array
                        (
                            [first_name] => Stephen
                            [last_name] => Gray
                            [avatar] => Stephen_Gray.png
                            [updated_by] => 13556
                            [id] => 399
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-20 09:59:16
                            [publish_date] => 10/20/09
                        )

                    [13] => Array
                        (
                            [first_name] => Alan
                            [last_name] => Chandler
                            [avatar] => Alan_Chandler.png
                            [updated_by] => 13549
                            [id] => 398
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-19 12:03:07
                            [publish_date] => 10/19/09
                        )

                    [14] => Array
                        (
                            [first_name] => Mark
                            [last_name] => Howell
                            [avatar] => Mark_Best.png
                            [updated_by] => 13561
                            [id] => 396
                            [title] => 
                            [synopsis] => 
                            [create_date] => 2009-10-17 12:30:16
                            [publish_date] => 10/17/09
                        )

                )

            [_count:protected] => 15
        )

    [_currentItemCount:protected] => 
    [_currentItems:protected] => 
    [_currentPageNumber:protected] => 1
    [_filter:protected] => 
    [_itemCountPerPage:protected] => 5
    [_pageCount:protected] => 3
    [_pageRange:protected] => 10
    [_pages:protected] => 
    [_view:protected] => 
)
4

1 に答える 1

4

ザックが書いたように、あなたは行方不明です

$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber(1);

ページネーター コントロールとページネーター内の項目をレンダリングするビュー スクリプトを作成できること。

あなたが電話しなければならないよりも

$paginator->getPages()->pageCount

Zend_View を使用しておらず、paginatorControl ビュー ヘルパーである場合。

于 2009-11-02T21:39:41.603 に答える