<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr</title>
<link>http://snipplr.com/tags/database</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Wed, 09 Jul 2008 05:03:28 GMT</pubDate>
<item>
<title>(PHP) PEAR::DB MySQL Functions - mikegreen</title>
<link>http://snipplr.com/view/6419/peardb-mysql-functions/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Thu, 22 May 2008 11:26:26 GMT</pubDate>
<guid>http://snipplr.com/view/6419/peardb-mysql-functions/</guid>
</item>
<item>
<title>(PHP) PHP Class: MySQL DB Class - mattkenefick</title>
<link>http://snipplr.com/view/6416/php-class-mysql-db-class/</link>
<description><![CDATA[ <p>I deleted the old one by accident trying to edit it.</p> ]]></description>
<pubDate>Thu, 22 May 2008 10:25:37 GMT</pubDate>
<guid>http://snipplr.com/view/6416/php-class-mysql-db-class/</guid>
</item>
<item>
<title>(Other) listValues function - Meestercor</title>
<link>http://snipplr.com/view/6406/listvalues-function/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Thu, 22 May 2008 08:21:46 GMT</pubDate>
<guid>http://snipplr.com/view/6406/listvalues-function/</guid>
</item>
<item>
<title>(PHP) PHP MySQL Connect - mikegreen</title>
<link>http://snipplr.com/view/6380/php-mysql-connect/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 21 May 2008 10:33:15 GMT</pubDate>
<guid>http://snipplr.com/view/6380/php-mysql-connect/</guid>
</item>
<item>
<title>(PHP) Simple PHP ViewObject generator - donkawechico</title>
<link>http://snipplr.com/view/6033/simple-php-viewobject-generator/</link>
<description><![CDATA[ <p>Any time I make PHP applications that interact with a database, I use this script. It generates one or more self-populating "View Objects" (a class that represents a single record from a DB). For example, rather than access a MySQL record-set by array indices (e.g. $row[1]), you can populate an object with the record's values, and reference them like properties in an object (e.g. $productVO->price).

To use:
1. Create a ".vo" file. For example, if you have a Products table, make "products.vo". 
2. In this file, you will map column names to some string of your choice. This string will be used to name the getter/setter functions in the generated class. "get" and "set" will be pre-pended to these mapped names automatically, so don't include them. Like so:
[column 1 name]:[desired function name]
[column 2 name]:[desired function name] ...
e.g. 

file "product.vo":

id:Id
price:Price
desc:Description

This will generate a class with functions "getId()", "getPrice()", and "getDescription()", returning the appropriate attribute.
3. Edit the folder names in the python source below to match your setup
4. Run ./voGenerator.py -a

This will generate views for all ".vo" files in the directory specified in the python script as well as an "AllViews.php" file which, when included in your PHP code, imports all view files. View files take the form [filename]VO.php as in ProductVO.php

To populate these objects, use the following snippit:

function getAllProducts() {
		$products = array();
		$row = array();
		$result = query("SELECT * FROM products");

		while ($row = mysql_fetch_assoc($result)) {
			$pVO = new ProductsVO;
			$pVO->populate($row);
			array_push($products, $pVO);
		}

		return $products;
}</p> ]]></description>
<pubDate>Mon, 28 Apr 2008 18:54:13 GMT</pubDate>
<guid>http://snipplr.com/view/6033/simple-php-viewobject-generator/</guid>
</item>
<item>
<title>(Visual Basic) Excel spreadsheet to MySQL Table inserts - jeffreality</title>
<link>http://snipplr.com/view/5993/excel-spreadsheet-to-mysql-table-inserts/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Thu, 24 Apr 2008 17:41:39 GMT</pubDate>
<guid>http://snipplr.com/view/5993/excel-spreadsheet-to-mysql-table-inserts/</guid>
</item>
<item>
<title>(SQL) Storing an IP address in a database table - zingo</title>
<link>http://snipplr.com/view/5761/storing-an-ip-address-in-a-database-table/</link>
<description><![CDATA[ <p>You can store an IP address in an INT UNSIGNED (4 bytes) which is of course much more efficient and faster than a CHAR(15).
MySQL has two built-in functions: INET_ATON() and INET_NTOA(). These two functions are used allover the place in any TCP/IP stack implementation or even application.
The INET_ATON() function converts Internet addresses from the numbers-and-dots notation into a 32-bit unsigned integer, and INET_NTOA() does the opposite.</p> ]]></description>
<pubDate>Wed, 09 Apr 2008 20:31:52 GMT</pubDate>
<guid>http://snipplr.com/view/5761/storing-an-ip-address-in-a-database-table/</guid>
</item>
<item>
<title>(PHP) PHP connecting and query MySQL DB - mswallace</title>
<link>http://snipplr.com/view/5488/php-connecting-and-query-mysql-db/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 18 Mar 2008 23:13:05 GMT</pubDate>
<guid>http://snipplr.com/view/5488/php-connecting-and-query-mysql-db/</guid>
</item>
<item>
<title>(SQL) TSQL to Reset a Tables Primary Key Autonumber - rengber</title>
<link>http://snipplr.com/view/5102/tsql-to-reset-a-tables-primary-key-autonumber/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sun, 17 Feb 2008 20:42:49 GMT</pubDate>
<guid>http://snipplr.com/view/5102/tsql-to-reset-a-tables-primary-key-autonumber/</guid>
</item>
<item>
<title>(Other) YAML Symfony database.ymlの初期設定 - daisuke103</title>
<link>http://snipplr.com/view/5034/yaml-symfony-databaseyml/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 13 Feb 2008 00:43:41 GMT</pubDate>
<guid>http://snipplr.com/view/5034/yaml-symfony-databaseyml/</guid>
</item>
<item>
<title>(PHP) Remove Duplicate Rows - Abe</title>
<link>http://snipplr.com/view/4819/remove-duplicate-rows/</link>
<description><![CDATA[ <p>$duplicates checks and groups duplicated rows with the same field1 and field2 (like comments maybe) and $limit counts how many times a row is duplicated.</p> ]]></description>
<pubDate>Tue, 29 Jan 2008 12:10:40 GMT</pubDate>
<guid>http://snipplr.com/view/4819/remove-duplicate-rows/</guid>
</item>
<item>
<title>(PHP) MySQL Class Cheat Sheet - Abe</title>
<link>http://snipplr.com/view/4808/mysql-class-cheat-sheet/</link>
<description><![CDATA[ <p>Cheat sheet for the MySQL Databse Class</p> ]]></description>
<pubDate>Mon, 28 Jan 2008 11:59:58 GMT</pubDate>
<guid>http://snipplr.com/view/4808/mysql-class-cheat-sheet/</guid>
</item>
<item>
<title>(PHP) Usefull functions to work with MySQL under PHP5 - LoRd1990</title>
<link>http://snipplr.com/view/4594/usefull-functions-to-work-with-mysql-under-php5/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 15 Jan 2008 09:55:45 GMT</pubDate>
<guid>http://snipplr.com/view/4594/usefull-functions-to-work-with-mysql-under-php5/</guid>
</item>
<item>
<title>(C#) xml handler - zvasanth</title>
<link>http://snipplr.com/view/4431/xml-handler/</link>
<description><![CDATA[ <p>Everything is either true or untrue, or both true and untrue, or neither true nor untrue</p> ]]></description>
<pubDate>Sat, 29 Dec 2007 02:02:52 GMT</pubDate>
<guid>http://snipplr.com/view/4431/xml-handler/</guid>
</item>
<item>
<title>(R) typo3 open database connection - jpdamen</title>
<link>http://snipplr.com/view/4401/typo3-open-database-connection/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 21 Dec 2007 18:32:18 GMT</pubDate>
<guid>http://snipplr.com/view/4401/typo3-open-database-connection/</guid>
</item>
<item>
<title>(Ruby) Ruby One-liner for Restoring One Table from a Huge SQL Dump - ches</title>
<link>http://snipplr.com/view/4198/ruby-oneliner-for-restoring-one-table-from-a-huge-sql-dump/</link>
<description><![CDATA[ <p>Courtesy of Jesse.</p> ]]></description>
<pubDate>Tue, 27 Nov 2007 10:55:45 GMT</pubDate>
<guid>http://snipplr.com/view/4198/ruby-oneliner-for-restoring-one-table-from-a-huge-sql-dump/</guid>
</item>
<item>
<title>(SQL) MySQL LOAD DATA INFILE with WHERE - bassnode</title>
<link>http://snipplr.com/view/4140/mysql-load-data-infile-with-where/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Thu, 15 Nov 2007 15:22:18 GMT</pubDate>
<guid>http://snipplr.com/view/4140/mysql-load-data-infile-with-where/</guid>
</item>
<item>
<title>(SQL) Ordering multiple SELECT statements in a UNION - andyhartleeds</title>
<link>http://snipplr.com/view/4076/ordering-multiple-select-statements-in-a-union/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 06 Nov 2007 08:43:28 GMT</pubDate>
<guid>http://snipplr.com/view/4076/ordering-multiple-select-statements-in-a-union/</guid>
</item>
<item>
<title>(SQL) Generate Simple Bar Charts From a MySQL Prompt - zingo</title>
<link>http://snipplr.com/view/3934/generate-simple-bar-charts-from-a-mysql-prompt/</link>
<description><![CDATA[ <p>You can generate a simple bar chart of the values by executing this command...</p> ]]></description>
<pubDate>Fri, 19 Oct 2007 00:40:13 GMT</pubDate>
<guid>http://snipplr.com/view/3934/generate-simple-bar-charts-from-a-mysql-prompt/</guid>
</item>
<item>
<title>(SQL) List all Stored Procedures in an Oracle Database - rengber</title>
<link>http://snipplr.com/view/3776/list-all-stored-procedures-in-an-oracle-database/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 24 Sep 2007 15:31:54 GMT</pubDate>
<guid>http://snipplr.com/view/3776/list-all-stored-procedures-in-an-oracle-database/</guid>
</item>
</channel>
</rss>