Php Object Generator Tutorials
  1. Introduction to POG
  2. Setting up PHP, MySQL etc.
  3. Designing your objects
  4. Generating your code
  5. Description of the generated code
  6. Edit configuration file
  7. The Setup Process
  8. Using the code: Save()
  9. Using the code: Get()
  10. Using the code: SaveNew()
  11. Using the code: GetList()
  12. Using the code: Delete()
  13. Using the code: DeleteList()
  14. Advanced: object relations
  15. Advanced: Set{Parent}()
  16. Advanced: Get{Parent}()
  17. Advanced: Add{Child}()
  18. Advanced: Get{Child}List()
  19. Advanced: Save(deep)
  20. Advanced: Delete(deep)
  21. Advanced: Add{Sibling}()
  22. Advanced: Set{Child}List()
  23. Advanced: Set{Sibling}List()
  24. Advanced: Get{Sibling}List()
  25. Advanced: DeleteList(deep)
  26. Customizing POG-generated code
  27. Customizing: Extending POG Objects
  28. Customizing: Plugins
  29. Examples
  30. Examples: User registration system
  31. Examples: User authentication
  32. Examples: Survey form
  33. Examples: Using POG with AJAX
  34. PDO: Introduction
  35. PDO: SQLite example
  36. PDO: Firebird example
  37. PDO: PostgreSQL example
  38. PDO: MySQL example
  39. PDO: ODBC example
  40. Troubleshooting
  41. Troubleshooting: Data appears encoded
  42. Troubleshooting: Can't regenerate object
  43. Troubleshooting: Can't seem to Save()
  44. Troubleshooting: Can't get object / object attributes from database
  45. Troubleshooting: Can't open zip file on Mac
  46. Troubleshooting: Setup screen is blank
  47. Videos
  48. Appendix: Creating table(s) manually
  49. Appendix: Regenerating objects
  50. Appendix: Generating objects using SOAP
  51. Case Study: Gravity GTD
  52. Case Study: Web Form Factory


Want more Php Object Generator?
Back to the Code Generator
The POG Weblog and RSS feed.
The POG Google group


PDO: SQLite example


NOTE: The example is now obsolete, due to the fact that POG stopped out-of-the-box support for databases other than MySQL

Using Php 5.1+ with an SQLite database is very useful when your host doesn’t have MySQL already installed. More information about the SQLite database can be found here. In a few words: SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine

Using Php Object Generator, you can generate objects for Php 5.1 which connect to an SQLite database through the PDO interface.

The following example will show you how to create a simple feedback form using Php Object Generator and SQLite. Requirements: Php 5.1, SQLite 3:

First, create the feedback form HTML:

Check that the feedback form is correct by opening it in your browser:

Download the code

Since we are using the SQLite database instead of MySQL, we need to perform a few more steps before we’re able to use the POG-generated code.

First download the SQLite Database Browser. It’s available as a free download on sourceforge. Once the SQLite Database Browser is on your system, you’ll be able to easily create and manage your SQLite databases.

Next, download the SQLite 3 binary

At this point, you should have something like this in a folder somewhere on your system:

Next either use SDB or the command line utility to create an SQLite database called “test.db”. Then run the generated SQL query on this database. This should create the table to store your Feedback object.

Once your database has been created, you should see that a file (test.db) has been created in your directory

All we need to do now is process the data that’s submitted from the feedback form, create a FEEDBACK object and Save it to the database.

This is the simplified code to process the data when the form is submitted:

PHP:
$feedback= new Feedback();
$feedback->name = $_POST['name'];
$feedback->email = $_POST['email'];
$feedback->comment = $_POST['comment'];
if ($feedback->Save())
{
    echo "feedback successfully saved";
}

A simple test to check if the feedback system works:

Note: MAKE SURE THAT YOUR SERVER HAS WRITE PERMISSION ON THE ENTIRE FOLDER SO THAT THE PHP SCRIPT CAN WRITE TO THE SQLITE DATABASE.

DOWNLOAD SOURCE FOR THIS TUTORIAL





POG documentation summary: