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

Dalibor Karlović:
Testing your Symfony application on production
Oct 05, 2015 @ 09:14:50

In a new tutorial Dalibor Karlović shows you how to test your Symfony application in production to get a more "real world" picture of how your application is performing for the rest of the world.

The problem here is that you almost cannot guarantee that you can replicate the production environment down to a single detail, it might have a slightly different underlying system, a slightly different network setup, even a different updates applied might mean it works for you, but not on production.

He starts the post by talking about the testing support already built into Symfony and the different parts tested by unit versus functional tests. He gets into some actual (functional) test examples, showing how to evaluate the response from an API request and where the major part of the overhead is - the database interaction. He takes the next step and looks at how to avoid "impure" functional testing and only then starts talking about switching between database types (SQLite vs MySQL) for better performance measurements. Finally, he gets to the topic of the article, running tests in production, and includes a "gotcha" to look out for (hint: don't hard-code IDs).

tagged: test symfony application production functional unit sqlite mysql

Link: https://medium.com/@dkarlovi/testing-your-symfony-application-on-production-a143483768c9

Android Login and Registration with PHP, MySQL and SQLite
Feb 02, 2012 @ 10:41:21

On the AndroidHive site there's a recent tutorial (plus screencast) about combining PHP, MySQL and SQLite to act as the backend authorization for your Android application.

In my previous article Android Login and Registration Screen Design i explained designing the login and registration interfaces, but it has no functionality. In this tutorial i am explaining how to build complete login and registration system in android using PHP, MySQL and SQLite. Also this tutorial covers how to build simple API using PHP and MySQL.

The tutorial walks you through each step of the process:

  • Creating MySQL Database and Tables
  • Building PHP API Classes
  • Starting Android Project
  • Making the JSON Parser, SQLite Database Handler and User Functions Classes
  • Designing the Screens
  • Switching between Activities
  • Finally Updating AndroidManifest.xml

If you want to get started quickly, you can just download the final result and go.

tagged: android api login authentication mysql sqlite application mobile


Full-text Search with SQLite
Nov 15, 2011 @ 09:53:50

On the php|architect site there's a recent tutorial from Jeremy Kendall about full-text searching in SQLite, a lightweight database alternative that, since it's stored locally, can be used without a full database server.

Full-text search with SQLite is so ridiculously easy to implement, there are only two valid reasons you haven’t done it yet. The first is you don’t need the full-text capability, and the second is you didn’t know it could be done.

In his method he creates a full-text search table (using fts4) and populating it with your data. You can use the "MATCH" keyword in your SQL to find the closest matches and even handy modifiers like "NEARBY", wildcards and token/prefixes in queries. For more detailed information, check out the SQLite documentation for a full guide.

tagged: fulltext sqlite search fts4 table


SQLite PHP tutorial
Oct 17, 2011 @ 12:12:48

If you're in the process of prototyping a site or just need a lightweight storage tool for your application, you might look into SQLite. Fortunately, PHP has direct support for it and this great tutorial from ZetCode.com will introduce you to some of the basic concepts you'll need to get working (it's a bit older, but still very useful).

This is a PHP programming tutorial for the SQLite database. It covers the basics of SQLite programming with PHP language. There are two ways to code PHP scripts with SQLite library. We can use procedural functions or OOP objects and methods. In this tutorial, we use the classical procedural style. You might also want to check the PHP tutorial or SQLite tutorial on ZetCode.

They go through the basic installation (on a linux platform, but easily adapted to others) including changes to your php.ini and the creation and use of a first sample database. You'll find the interface very similar to some of its other RDBMS cousins with a few exceptions. They show you the CRUD basics - creating records, reading the contents of a table, updating data already there and deleting records. There's also a simple form tutorial that takes a name and gender and does the inserts.

tagged: sqlite tutorial crud form example


Use PDO to Access Just About Any Database from PHP
Apr 25, 2011 @ 08:17:51

New on PHPBuilder.com there's a tutorial from Leidago Noabeb about using the PDO functionality that comes installed on many PHP platforms out there to access just about any database you might need to work work. This includes technology like MySQL, DB2, SQLite and PostgreSQL.

PHP Data Objects, or "PDO" as it is commonly known, is a lightweight database abstraction layer that is arguably the best, at least in terms of speed. A great deal of this speed is owing to the fact that the PDO extension was compiled with C/C++. The extension became available in PHP5, and as with any other database abstraction layer, its aim is to provide a uniform interface to access a variety of databases. This is also a way for developers to create portable code for a variety of platforms.

The tutorial shows you how to find the enabled PDO connection types for your installation (and where to go if you have access to turn more on or off). They show an example connection - in this case, to a MySQL database - and how to run a query or two using this new resource.

tagged: pdo access database tutorial mysql sqlite postgresql


Johannes Schluter's Blog:
Changes in PHP trunk: No more extension for sqlite version 2
Nov 22, 2010 @ 13:49:05

Johannes Schluter has a quick new post to his blog today talking about parts of the sqllite extension that will be dropped from the core - the current sqlite_* methods and the pdo_sqlite driver.

The issue there is that this depends on the SQLite 2 library which isn't supported by upstream anymore for a few years. It was a logical step therefore to remove this extension from PHP trunk. The support for the sqlite3 extension and the PDO_sqlite driver (same link as above, read it carefully), which use version 3 of the library, are continued.

The change probably won't be happening in any of the PHP 5.3.x releases but should becoming in PHP 5.4 so, as he advises, you might need to rebuild your database file and change your application to correct things for the changes.

tagged: change trunk sqlite remove pdosqlite extension sqlite3


Creating a Web Poll with PHP
Sep 03, 2010 @ 08:26:42

On NETTUTS.com today there's an intermediate tutorial showing you how to create a simple polling system for your site - complete with a database backend and a CSS styled results view.

Polls are nearly ubiquitous on the web today, and there are plenty of services that will provide a drop-in poll for you. But what if you want to write one yourself? This tutorial will take you through the steps to create a simple PHP-based poll, including database setup, vote processing, and displaying the poll.

They include all of the code and markup you'll need ready for cut & paste - the SQL for the database backend (they chose SQLite), the HTML for the question and answer sides and the CSS to style them both. No javascript is needed to make the example work. There's even some process flows to help you understand the paths the application can take.

tagged: poll tutorial sqlite css database


FWebDe Blog:
Use SQLite For Your Next PHP Project
Aug 12, 2010 @ 09:19:20

On the FWebDe blog there's a recent post from Eric Bannatyne about using SQLite in your next project.

SQLite is one of those awesome pieces of software known for its "liteness". It is, as you can guess from the name, a database designed to have as small a footprint as possible. SQLite is a very popular database, in fact, it is believed to be the most widely deployed SQL database engine in the world.

He gives some reasons why to choose this database tool and introduces you to some of the basics - creating a database, connecting to it from PHP and running a query. He ties this all together in a complete example of connecting to the database and inserting post information into a table.

tagged: sqlite database tutorial pdo


Hasin Hayer's Blog:
Converting standard wordpress into a SQLite powered multi user blogging platform
Sep 22, 2009 @ 12:51:52

Hasin Hayder has posted about a method for turning a normal WordPress installation into a muilt-user blogging system backed by an SQLite database.

Wordpress is one of the very popular blogging platform which is not only free but also released as a open source project. officially wordpress runs only on mysql. so if you want to run it with SQLite, you will not find any official support for that.

He has five steps in his process for converting the backend away from MySQL and over to SQLite:

  • Add a wildcard to your DNS setup for the hostname you're using
  • Install WordPress
  • Install PDO for WordPress
  • Create the directory where the user databases will exist
  • Change the database configuration to write to a SQLite database file based on the hostname (which is what the DNS wildcard makes easier)
tagged: convert wordpress sqlite tutorial pdo


Mark Karpeles' Blog:
SVN error 200030 – It's PHP's fault!
Aug 06, 2009 @ 09:06:56

Mark Karpeles found a problem when he updated his Subversion install to the latest in the 1.6.x series - an XML error about opening the filesystem.

After some searches I found someone who had the same problem, and fixed it. Basically the problem is due to the SQLite version embed into PHP 5.2.x. PHP includes SQLite 3.3.7 while SVN will usually depend on 3.6.15 (or whatever you have on your system).

There's three solutions to the issue - disable PHP, update SQLite or create a new repository with the "-pre-1.6-compatible" flag to make it all play nicely together.

tagged: svn sqlite version fix