News Feed
Sections




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

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/

blog comments powered by Disqus

Similar Posts

Conor Mac Aoidh's Blog: OS X: Audio Alerts for PHP Errors

PHPMaster.com: Creating a PHP OAuth Server

Fawad Hassan's Blog: Load More Using KnockoutJS, PHP/CodeIgniter (Part 1)

Edin.dk: PHP 4.4 for windows with newer MySQL libraries

Rasmus Larsson: Building a template engine in PHP


Community Events

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


wordpress series opinion release api introduction version interview voicesoftheelephpant laravel library podcast community extension laravel5 list unittest language php7 framework

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