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:
Cursors in MySQL Stored Procedures
February 05, 2014 @ 12:48:43

On the SitePoint PHP blog there's a new tutorial showing how to use cursors in MySQL stored procedures via PHP. A cursor is a piece of functionality that lets you work with the data in the data found by the stored procedure.

With cursors, we can traverse a dataset and manipulate each record to accomplish certain tasks. When such an operation on a record can also be done in the PHP layer, it saves data transfer amounts as we can just return the processed aggregation/statistical result back to the PHP layer (thus eliminating the select - foreach - manipulation process at the client side).

He provides a more real-world situation to help illustrate their use - working with information about the Lakers basketball team. He includes an example of a stored procedure to find a "streak" of games that they've won (yearly too). A quick PHP script is included showing how to call the stored procedure and fetch the data. The PHP doesn't directly use the cursor, it's self-contained inside the stored procedure.

0 comments voice your opinion now!
mysql stored procedures tutorial cursor

Link: http://www.sitepoint.com/cursors-mysql-stored-procedures/

Derick Rethans' Blog:
MongoDB Cursors with PHP
May 22, 2012 @ 12:23:16

Derick Rethans has a new post to his site today about MongoDB cursors in PHP when using the PHP driver and how it handles pulling data from the server.

Recently I was asked to improve the MongoCursor::batchSize documentation. This began an indepth investigation in how the PHP driver for MongoDB handles pulling data that's been queried from the MongoDB server. Here are my findings.

He talks about the cursor that's created when a "find" call is made and how you can add on additional options (via other methods on the cursor) to its execution. He also covers how you can set your own batch size, using limit to only fetch a certain number of results and combining the two to make for more memory efficient, yet complete, returned data sets.

0 comments voice your opinion now!
mongodb cursor batchsize limit tutorial


PHPMaster.com:
MongoDB Revisited
January 17, 2012 @ 12:44:07

In this new post to PHPMaster.com today Ahmed Shreef continues on from his previous introduction to MongoDB and gets into more detail on things like cursors, query operators, queries on embedded documents and the sort/skip methods.

In my previous article Introduction to MongoDB I discussed installing Mongo, its PHP extension, and how to perform simple insert and find operations. Of course there are many, many more features than what I mentioned so I wanted to write another article to show you some of them.

Other topics mentioned include queries on arrays of data and running queries with indexes to improve their performance. Code is also included for each example.

0 comments voice your opinion now!
mongodb tutorial cursor query index sort skip


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



Community Events





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


install library podcast release interview update tips laravel list community zendserver package framework symfony language api introduction series deployment opinion

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