In this new post to his blog Johannes Schluter looks at creating a storage engine plugin for MySQL via its plugin interface.
MySQL 5.1 has a plugin interface to easily add storage engines. PHP can easily embedded into other applications. So why not combine these two things? - Writing a MySQL Storage Engine which reads data by calling a PHP script.
He starts with a basic example with create_table and open_table functions that can pull the data from the table marked with the "Engine" setting of PHP. He expands on this to allow for more functionality - update, delete and write methods are added.
DevShed continues their series focusing on the CodeIgniter framework with the seventh part - a look at interacting with the database to update, delete and insert rows from your application.
You've seen some of the things you can accomplish with the Code Igniter PHP framework in earlier parts of this series. In this seventh part of the series, you will learn, through copious examples, how to perform insertions, updates and deletions on a selected MySQL table by using Code Igniter's database class. You'll see that these tasks are very intuitive and easy to grasp, thanks to Code Igniter's friendly learning curve.
They show how to make conditional select statements (with where clauses) and do both inserts of new information and updates to current information, all with the built-in model functionality the framework provides.
The ProDevTips blog has posted the fifth part of their look at using Doctrine with PHP. This time they focus on file uploads.
It's time to take a look at how file uploads can be integrated into the Doctrine validation and CRUD process. We will have a product in the form of a digital download as an example, it will have a screenshot image that can be maximum 250 pixels wide and high. The download itself will be a zipped file.
They set up their table definitions first and set up a few validation functions (update, insert and for the file data) to work on top of that. Custom upload/uploadImage and save methods handle the user's submission while a simple delete method makes removing images easy.
In this new post on Raphael Stolt's blog, he shows a way that you can take XML that holds SQL information (in his example INSERTs and DELETEs) and transforms them into SQL statements via XSL stylesheets.
A canny data import technique that emerged from praxis, while working on the import of data-centered XML resources, is utilitizing the abilities of Xslt. The generation of the required SQL statements actually only needs a simple Xsl stylesheet which might import for an PHP XSLTProcessor object or pass to the xsltproc command line tool. Both further described approaches are based upon the libxslt library and are assuming the use of XSLT 1.0.
He starts with an example bit of XML that has the XSL stylesheet at the top that will be used to transform the data and the information to perform inserts on several "partner" values in the XML below. Following this, he creates a PHP class to load the file and apply the stylesheet.
He also mentions a few different approaches to the same problem - XSLTProcessor class approach returning a single SQL string , xsltproc approach and the XSLTProcessor class approach using the ability to use PHP functions as XSLT functions.
The DeveloperTutorials website has a quick new article today talking about the insertion of an entire array into a database:
A few days ago, a user came into #phphelp on UnderNet wanting to know how to insert an array into a database. A simple enough concept, but how exactly does one look up information on the subject? The goal is to take a form with multiple input sets (like a list of people, their phone numbers, etc.) and input multiple rows into a database.
They create the database and a simple form to get the array input from before sharing the code to grab the information and loop through them all and drop them into the database table.
DevShed has posted the second part of their (three part) series looking at the construction of a blogging application in PHP5. In this part, they look at how to handle the user's desire to input entries into the application via a HTML form.
In this second installment of the series, I'll show you how to expand the initial functionality of the already familiar "BlogProcessor" class so that it is capable of addressing all these (displaying all the entries, show the insert/update forms) issues.
They start with the simplest of the group - the displayBlogs method, outputting the full contents of the entries for the blog. Things get a bit tougher with the next step - creating the insert and update forms for pushing content into the database. Finally, they defined the header and footer functionality to make setting up the structure of the page simpler.
DevShed is continuing their series on working with an invoicing system in PHP with this second part, a look at the actual invoicing system they created the login for previously.
If you're running a business in which you're invoicing clients, you need some way to keep track of which invoices have gone out and which clients have paid. In this second article of a four-part series that covers the creation of a PHP invoicing system, we create the parts that deal with this kind of invoice management.
First off, they build out the select to pull out the invoice information and create the page to display the results on. They move to the other side of things, and create the form to set up an invoice, outputting it in a PDF format. To make it easier to see which of the invoices are unpaid, they also create a small section at the top of the list. And, last but not least by any means, they show you how to enter in a brand new invoice record into your database using the FCKeditor to make entering the actual contents of the invoice simple.
On NewsForge, an article with a look at phpMyAdmin has been posted, a "getting started" guide for those not familiar with the software.
So many open source projects depend on MySQL that it's almost impossible for administrators and other open source enthusiasts to avoid working with at least one MySQL database. MySQL's command line interface is easy enough to use, but if you don't feel like reaching for a five-pound MySQL reference book or Googling for proper SQL syntax, phpMyAdmin is a great alternative to learning MySQL commands by heart.
They take a brief look at how it's set up, though it's not an installation tutorial, more about configuration. They guide you through some of the interface before getting to the real functionality - inserts, selects, dumping/restoring data, working with users, and checking/repairing tables when things go awry.
The A/R/T article repository (from php|architect) has posted the second part of their series covering stored procedure programming in MySQL by Ligaya Turmelle.
Now that we become familiar with the fundamentals of stored procedures it is time to start playing with the "Big Boy Toys". This article will go over stored procedures's built in error handling, the security features available, various "extras" available, what isn't allowed in a stored procedure, and some basic administration of the stored procedures. So lets stop talking and bust open the toy box and start playing!
Since they've already gotten the groundwork laid in the previous article, they jump right into the transactions in this part. In this example, they create a "mass insert", show hoe to create some error handling, add in a dash of security, and toss in a few extras. There's also a few small gotchas included to watch out for.
Lukas Smith has an example of how to use his MDB2 package in one of his latest blog posts.
I just wanted to show case some of the new features in MDB2. I especially wanted to demo some PHP5 specific features. The following example just creates a table with an autoincrementing primary key column 'id', inserts some values, fetches the last inserted id and finally, after selecting those values and outputs them using an iterator, drops the table again...
The example should work with MySQL and PostgreSQL, but not with SQLite (due to a limitation in the SQLite API). The MDB2 library makes interfacing with the database nice and clean, using functions like prepare(), execute() and query() to do the hard work for you.