Location: PHPKode > projects > WaterFlea Database Maintenance Tool > waterflea-0.6-beta/include/_DbProperties.php
<?php

/*#####################################################################################

WaterFlea - Database Maintenance Tool
Copyright (C) Benjamin Rafael F. Intal

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

WaterFlea project site is at http://www.sourceforge.net/projects/waterflea/
WaterFlea website is at http://waterflea.sourceforge.net/

If you have questions or suggestions, please visit the said URLs above,
or you could contact me via email at <hide@address.com> - just mention in the
WaterFlea in the subject and what it's all about.

#######################################################################################*/


/*
	TABLE FIELD PROPERTIES
*/

/*
checkingCondition values:
  equals
  contains
*/


$properties['PrimaryKeys']['fieldProperty'] = 'Key';
$properties['PrimaryKeys']['checker'] = 'PRI';
$properties['PrimaryKeys']['checkingCondition'] = 'equals';
$properties['PrimaryKeys']['fieldIsEditable'] = 1;
$properties['PrimaryKeys']['desc'] = 'Primary keys of the table';

$properties['CurrentTimeStamp']['fieldProperty'] = 'Field';
$properties['CurrentTimeStamp']['checker'] = '_stampCurrent';
$properties['CurrentTimeStamp']['checkingCondition'] = 'contains';
$properties['CurrentTimeStamp']['fieldIsEditable'] = 0;
$properties['CurrentTimeStamp']['desc'] = 'Fields with this property will contain the value of the current datetime upon saving';

$properties['AutoIncrements']['fieldProperty'] = 'Extra';
$properties['AutoIncrements']['checker'] = 'auto_increment';
$properties['AutoIncrements']['checkingCondition'] = 'equals';
$properties['AutoIncrements']['fieldIsEditable'] = 0;
$properties['AutoIncrements']['desc'] = 'Auto-increment field';

$properties['Integers']['fieldProperty'] = 'Type';
$properties['Integers']['checker'] = 'int';
$properties['Integers']['checkingCondition'] = 'contains';
$properties['Integers']['fieldIsEditable'] = 1;
$properties['Integers']['desc'] = 'Fields that can only contain integers';

$properties['Passwords']['fieldProperty'] = 'Field';
$properties['Passwords']['checker'] = '_password';
$properties['Passwords']['checkingCondition'] = 'contains';
$properties['Passwords']['fieldIsEditable'] = 1;
$properties['Passwords']['desc'] = 'Fields with this property have their values encoded as password(\'xxx\')';

$properties['Enumerations']['fieldProperty'] = 'Type';
$properties['Enumerations']['checker'] = 'enum';
$properties['Enumerations']['checkingCondition'] = 'contains';
$properties['Enumerations']['fieldIsEditable'] = 1;
$properties['Enumerations']['desc'] = 'Enumerated field';

$properties['TimeStamps']['fieldProperty'] = 'Type';
$properties['TimeStamps']['checker'] = 'timestamp';
$properties['TimeStamps']['checkingCondition'] = 'equals';
$properties['TimeStamps']['fieldIsEditable'] = 1;
$properties['TimeStamps']['desc'] = 'Timestamp field';

$properties['UploadURL']['fieldProperty'] = 'Field';
$properties['UploadURL']['checker'] = 'url';
$properties['UploadURL']['checkingCondition'] = 'contains';
$properties['UploadURL']['fieldIsEditable'] = 1;
$properties['UploadURL']['isFileUpload'] = 1;
$properties['UploadURL']['desc'] = 'Contains an uploaded file\'s path';

/*
	MAIN SCRIPT
*/

$propertyNames = array_keys($properties);
$returnProperty = 'Field';

if ($getProperties == false)
{
	$arr = array();
	foreach ($propertyNames as $propertyName)
	{
		$arr[$propertyName] = array();
		foreach ($mysqlFetchedArray as $dbRow)
		{
			if ($properties[$propertyName]['checkingCondition'] == 'equals')
			{
				if ($dbRow[$properties[$propertyName]['fieldProperty']] == $properties[$propertyName]['checker'])
				{
					$arr[$propertyName][] = $dbRow[$returnProperty];
				}
			}
			else
			{
				$haystack = $dbRow[$properties[$propertyName]['fieldProperty']];
				$needle = $properties[$propertyName]['checker'];
				if (strpos($haystack, $needle) !== false)
				{
					$arr[$propertyName][] = $dbRow[$returnProperty];
				}
			}
		}
	}

	// get uneditable fields
	$temp = array();
	foreach ($propertyNames as $propertyName)
	{
		if ($properties[$propertyName]['fieldIsEditable'] == 0)
		{
			foreach ($arr[$propertyName] as $field)
			{
				$temp[] = $field;
			}
		}
	}
	$arr['uneditableFields'] = $temp;

	// get other properties
	// file upload
	$temp = array();
	foreach ($propertyNames as $propertyName)
        {
                if (isset($properties[$propertyName]['isFileUpload']))
                {
                        foreach ($arr[$propertyName] as $field)
                        {
                                $temp[] = $field;
                        }
                }
        }
        $arr['FileUploads'] = $temp;
}
?>
Return current item: WaterFlea Database Maintenance Tool