News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Paginating Real-Time Data with Cursor Based Pagination
July 11, 2014 @ 11:52:13

On the SitePoint PHP blog today a new tutorial has been posted introducing you to cursor-based pagination of real-time data, showing the results and allowing for easy click-through functionality.

Pagination is a technique for breaking large record sets into smaller portions called pages. As a developer, you should be familiar with implementing pagination, but implementing pagination for real time data can become tricky even for experienced developers. In this tutorial, we are going to discuss the practical use cases and solutions for real time data pagination and cursor based pagination.

He uses results from the Twitter and Facebook APIs in his examples, grabbing tweets matching the search term "php". He briefly explains some of the issues with real-time pagination and how it compares with standard pagination techniques. He uses the "after" and "before" functionality of each API to only pull the data needed, not the entire list of latest posts. This is added to a list in order and shown when the user view is refreshed. He includes the code for implementing the cursor-based handling and how to echo the results back out to a view.

0 comments voice your opinion now!
cursor pagination twitter facebook api tutorial realtime

Link: http://www.sitepoint.com/paginating-real-time-data-cursor-based-pagination/

SitePoint PHP Blog:
Building a Web App with Symfony 2 Finalizing
October 29, 2013 @ 11:49:01

On SitePoint's PHP blog they've posted the last part of their series about building a web application with the Symfony2 framework. In this latest part they cover a few more complex things you can do to add features to your application.

In Part 1 and Part 2 of this series, I have covered the basics of using Symfony 2 to develop a functioning web site. In this part of the tutorial, I will cover some more advanced techniques and finish the project with pagination, image watermarks and NativeQuery.

He uses the default image library to add the watermarks (GD) and adds in a new route to view the cover of the book with the watermark applied. He shows how to add simple pagination into the book listing page (via controller attributes) and the use of the NativeQuery Doctrine provides to do more complex queries.

0 comments voice your opinion now!
symfony2 application tutorial series pagination watermark nativequery

Link: http://www.sitepoint.com/building-web-app-symfony-2-finalizing/

MaltBlue.com:
Use RouteMatch in Zend Framework 2 For Easy Routing
May 02, 2013 @ 11:14:22

In the latest to his site Matthew Setter takes a look at easy routing with RouteMatch in Zend Framework 2 applications. The RouteMatch component gives you better control over your routing and lets you define "match paths" for URL to Controller mappings.

Today using Zend Framework 2 RouteMatch, Router and Request objects, I show you an easy way to dynamically update the current route. It's almost painlessly simple. [...] Well, like most things in web application development, what starts out simply in the beginner often grows more complex over time. So too is my once simple route.

His "simple" route started getting a bit out of control when he added in some pagination to the page (and query for the path match). He wanted to figure out how to re-render data with the same filters but show the next page of data. He shows how to use the RouteMatch component to achieve just this. He creates a custom module with a "listViewToolbar" helper that lets you read the router, request and handle the parameters sent via the URL. The "invoke" method is called to render the toolbar in the page, complete with the new settings.

0 comments voice your opinion now!
routematch zendframework2 tutorial routing http toolbar pagination

Link: http://www.maltblue.com/tutorial/use-zend-framework-2-routematch-for-dynamic-routing

PHPMaster.com:
Pagination with CodeIgniter
January 30, 2012 @ 12:15:22

On PHPMaster.com today there's a new tutorial showing you how to handle simple pagination in a popular PHP framework, CodeIgniter.

Pagination is particularly useful when you are coding an application that interfaces with a database. A large dataset might have hundreds of possible results for one query, and pagination creates a much nicer user experience. In this tutorial, I'll use CodeIgniter's pagination library to show you how you can create a paginated list of results from a MySQL database. Along the way, you'll also see how to fix a problem with the pagination links that the library might produce.

He starts on the backend, creating a model to work with Country information and includes a "fetch_countries" method to grab the limited/paged list. Next up is the controller with an "example1" method that looks to the URL to see what page it should be on. The view is simple enough - just outputting the results back without worrying about how many to show.

0 comments voice your opinion now!
codeigniter framework tutorial pagination mvc country


Brian Swan's Blog:
Paging Data with the SQL Server Drivers for PHP Simplified
January 27, 2011 @ 12:54:56

Brian Swan has simplified the pagination using the SQL Server drivers for PHP in his latest post. He shows how to use a cursor to move around in the result set from your query.

An oversimplified definition of a database cursor might be this: A cursor is database functionality that allows you to point to a certain location within a result set and allows you to move forward (and sometimes backward, depending upon the cursor type) through the result set one row at a time. [...] In the paging [scenario], I'll use a static cursor since that cursor type would seem to satisfy the requirements of many web-based applications.

He shows how to execute a simple query with a dynamic cursor by specifying it in the connection call. He then uses the sqlsrv_num_rows to find the number of records returned and a sqlsrv_fetch_array call to pull just the page you need. He also includes some handy code to paginate the results, complete with links.

0 comments voice your opinion now!
sqlserver driver pagination numrows tutorial cursor


Brian Swan's Blog:
How to Page Data with the SQL Server Drivers for PHP
July 22, 2010 @ 09:16:01

Brian Swan has a quick new post today about using the pagination feature in the latest version of the SQL Server driver for PHP.

So, with the final release of the 2.0 version of the driver coming soon, I thought it was high time I posted something about using the functionality that was added in the v1.1 driver (better late then never!). While I'm at it, I'll include code that shows how to do paging with the PDO driver. (Complete scripts attached to this post.)

He gives a basic example of paginated data that lets you move back and forth with simple text links on the page. The key is in the row_number function that lets you specify the block of records to return. Code is included for this and a few other modifications including numeric links to jump to certain pages in the results. All scripts are included as a download.

0 comments voice your opinion now!
sqlserver driver pagination tutorial feature


Eli White's Blog:
An intriguing use of lambda functions
March 11, 2010 @ 08:48:16

In a new post to his blog today Eli White takes a look at an interesting use of lambda functions he's figured out for a his development at work.

I found a very specific use out of the blue of Lambda functions that I have now used and I see as a great use-case. Which is specifically passing functions/logic from your Controller to your View. In the case of Goodsie, I'm using PHP for my templating language and as usual I'm trying to remove as much logic from my View as possible, while still allowing the view to be malleable.

His method centered around a pagination subview that he wanted to make flexible enough to work with both the standard page view and with an ajax request. Lambda functions came to the rescue by dynamically creating a function based on the request need.

0 comments voice your opinion now!
lambda function pagination subview tutorial


Zend Developer Zone:
Paging and Sorting Data with Zend Framework, Doctrine and PEAR (part 2)
January 04, 2010 @ 11:52:33

The Zend Developer Zone has posted the second part of their look at pagination with the combination of the Zend Framework, Doctrine and PEAR and how the Zend_Paginator component compares to the PEAR and Doctrine alternatives.

In the previous segment of this article, I introduced you to the Zend_Paginator class, which provides a flexible API for paginating any data collection, whether it is expressed as an array or a database result set. [...] This article will explore two such alternatives, the PEAR Pager class and the Doctrine Pager class, and give you a crash course in how you can use them to quickly add paging and sorting features to your PHP application.

The article gives examples for both of the other methods - a simple pagination of database information with the PEAR pager component (and other packages that can make the results more effective) and the creation of a Doctrine instance where the results are handled via a series of built-in method calls.

1 comment voice your opinion now!
tutorial zendframework pear doctrine pagination sort


PaperMashup.com:
Easy PHP Pagination
December 22, 2009 @ 10:38:08

In a new post to Ashley Ford's blog there's a tutorial on paginating your data (from an array of data pulled from a database) with a simple PHP script:

I've had a few pagination scripts over the years but I thought i'd share the one that i'm currently using as it's a useful script to have in your toolbox. As a developer you'll soon find a need to paginate data when displaying contents from the database, and rather than use JavaScript which could require all the data to be loaded into the page on load, we can use PHP to ensure that we're only requesting the data that we need from the database.

Some sample code is included showing how to use the LIMIT statement (there's similar features in the other major databases) to only pull a subset of the data needed back into your script. Some CSS is also included to make it all look a bit. You can see it in action here and download the source here.

1 comment voice your opinion now!
pagination tutorial database


Zend Developer Zone:
Paging and Sorting Data with Zend Framework, Doctrine and PEAR (part 1)
December 11, 2009 @ 09:43:29

On the Zend Developer Zone there's the first part of a series looking at pagination and sorting of data with the combination of the Zend Framework, Doctrine and PEAR.

When building database-backed applications, one of the important problems for a developer or user interface engineer involves making large data sets more manageable by, and therefore more useful to, application users. [...] Back in the good old days, adding pagination to a PHP application was mostly a manual task, involving offset calculations and custom query generation. In recent years, the task has become significantly simpler, mostly due to the presence of ready-made pagination components in most common frameworks.

His tutorial uses the Zend Framework, Doctrine and the Pager, MDB2 and Structures_Datagrid PEAR packages. He starts with a basic select and format kind of example to show a few lines per page. To improve it (for larger data sets) he shows how to use the Zend_Paginator to only grab the rows needed for the page. Finally, he adds in code to allow for column sorting, making it easy to reorganize the results how you'd like.

1 comment voice your opinion now!
zendframework pagination sorting doctrine pear tutorial



Community Events





Don't see your event here?
Let us know!


framework developer install community laravel language release refactor opinion symfony2 api code threedevsandamaybe testing interview unittest introduction list series podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework