ReadDb/ReadDb_MySQL.php 21

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
24 note: PRI=Primary Key, UNI=Unique index, MUL=multiple... seems to mean the same as UNI though
27 other collations can easily be added if needed
28 UNIQUE when Key=PRI,UNI, or MUL. FULLTEXT for fulltext index
69 i.e. fulltext index on this column
80 Hold an instance of the class
83 only allow the singleton to access this class
87 The singleton method
101 call function from the singleton
103 the returned array will contain at least this information
110 note: PRI=Primary Key, UNI=Unique index, MUL=multiple... seems to mean the same as UNI though
113 other collations can easily be added if needed
135 get columns information from information_schema
152 for PMA bc:
153 `[SCHEMA_FIELD_NAME]` AS `[SHOW_FULL_COLUMNS_FIELD_NAME]`
180 lookup indexes on all tables
190 i.e. $row['Index_type']=="BTREE"
191 non-unique index
194 unique index
195 if key is not yet set, we need it

SyncDb/SyncDb_MySQL.php 103

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
24 note: PRI=Primary Key, UNI=Unique index, MUL=multiple... seems to mean the same as UNI though
27 other collations can easily be added if needed
28 UNIQUE when Key=PRI,UNI, or MUL. MUL could also mean NONUNIQUE. FULLTEXT for fulltext index
69 i.e. fulltext index on this column
113 options... all booleans
120 Hold an instance of the class
123 only allow the singleton to access this class
127 The singleton method
147 for each table
149 table does not exist
153 table exists
156 lookup indexes on this table ("SHOW FULL FIELDS" doesnt provide all of this)
160 get indexes by columnname
163 get column for this index
165 force index type to FULLTEXT or UNIQUE. if not fulltext, assume it's a unique
167 Index_type == BTREE
176 if an index exists for this column already, remove it
179 an index exists already
180 ie PRIMARY, 'id', whatever. references the index
181 ie PRIMARY, 'id', whatever. references the index
184 this index is not our PRIMARY index, so let's remove it
186 dont use this index
189 this index man be our PRIMARY index, so let's remove the OLD index
195 ie PRIMARY, 'id', whatever. references the index
196 ie FULLTEXT, UNIQUE, or NONUNIQUE
200 get regular column properties of the table
204 first- delete fields and 'track' updates, removal of keys, and removal of indexes
206 for each field in this table
209 set indexes. "IndexType" is not provided in the $currentField assoc ("SHOW FULL FIELDS FROM `$tableName`" doesn't provide this)
211 see if indexType is set
215 if key is not yet set, we need it for non-fulltext indexes.
217 unique
218 nonunique
222 need this field for sync
223 $currentField['IndexName'] = ""; //dont need this for sync
228 delete rows in current db table that are not in new db structure
231 Message(" ---- Field '<b>".$fieldName."</b>' exists. Comparing properties...");
233 mark field as found in current db table
238 drop keys and indexes
241 update fields that already exist to remove auto_increment so we can drop keys and indexes
244 only update auto_increment fields
250 drop indexes
257 drop keys
263 then add indexes on fields that already exist
266 indexType can be UNIQUE or NONUNIQUE
271 then add fulltext indexes on fields that already exist
278 add new keys on fields that already exist
285 update fields that already exist to their final structure (includes auto-increment)
294 insert new fields (including keys and indexes on those fields)
315 inserts any fields in $newDbStructure that do not have the ['verified'] flag set
317 table was created by us now. no need to check it
321 skip this entry
322 if verified flag is not set, field doesnt exist in db
331 compares the two fields, adding the fields to $this->_fieldsToUpdate[], $this->_indexesToDrop[], and/or $this->_keysToDrop[] if necessary
333 print_r($currentField);
334 print_r($newField);
345 go through all properties to see what (if anything) needs updated
348 properties to ignore
354 Collation is a special case. Ignore it always unless it's set in the new structure
359 Collation only applies to string types: "CHAR, VARCHAR, the TEXT types, ENUM, and SET data types"
361 data type does not suppport collations
365 valid collation
371 check for index type changes (ie fulltext)
396 special case where MUL==UNI
401 check for primary/unique key changes
402 remove primary key
418 end switch
419 end foreach
421 regular update
424 remove unique or fulltext index
427 remove primary key
430 add unique index
433 add fulltext index
436 add primary key
450 copy structure with keys and indexes
451 copy data
476 non-unique index
539 compile default value for CURRENT_TIMESTAMP
544 blob/text types cant have default values in mysql. make sure it's not an enum though that may contain the text 'text' or 'blob'
549 no quotes around default value
553 quote default value
575 does not update indexes/primary keys. use AddPrimaryKey and AddIndex for that...
587 compile default value
592 blob/text types cant have default values in mysql
597 no quotes around default value for CURRENT_TIMESTAMP
601 quote default value
613 Collation only applies to string types: "CHAR, VARCHAR, the TEXT types, ENUM, and SET data types"
614 returns TRUE if collation is valid for the given data type, false if not
615 reference: http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html
618 char and varchar
619 tinytext, text, mediumtext, and longtext
620 enum
621 enum
622 valid
624 not valid
629 Collation only applies to string types: "CHAR, VARCHAR, the TEXT types, ENUM, and SET data types"
631 forced character set
632 reference: http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html
643 no need for more yet. also may need to add a collation option
651 table not yet backed up
661 echo $str."<br>\n";

SmartDatabase.php 236

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
15 PHP 5.3.0 is required. removing this check for performance. PHP <5.3 is considered EOL now
16 if (strnatcmp( ($version=phpversion()), '5.3.0') < 0){ //check php constraints. eventually we'll get rid of this when everyone is 5.3.0+
17 throw new Exception("This version of SmartDatabase only works with PHP versions 5.3.0 and newer. You are using PHP version $version");
18 }
28 should update this for ANY change to structure at least. used for determining if a serialized SmartDatabase object is invalid/out of date
30 ///////////////////////////// SERIALIZATION - At top so we don't forget to update these when we add new vars //////////////////////////
45 ////////////////////////////////////////////////////////////////////////////////////
50 readonly. set in constructor
85 DbManager - The DbManager instance that will be used to perform operations on the actual database. If null, no database operations can be performed (use for 'in-memory' instances)
86 string - the database schema file to load. If left null, you will need to either build the database yourself useing ->AddTable() or load a schema from XML using ->LoadSchema()
87 boolean - development mode toggle. When true, does extra verifications (ie data types, columns, etc) that are a must for development, but may slow things down a bit when running in production.
88 boolean. if true and in $DEV_MODE, warnings will be shown for like missing classes and etc.
89 string (i.e. "GMT", "CST"). if set, sets the DefaultTimezone to this value . using "date('T')" will use php's default date timezone that is currently set and can be changed with a call to "date_default_timezone_set(...);". empty will use default system time (not recommended)
98 default options
99 'db-manager' => null,
100 reverse compatibility
106 reverse compatibility. constructor used to be (DbManager $dbManager=null, $xmlSchemaFilePath=null). now it's an array. need to support old versions though
109 first parameter is DbManager
112 merge in default options
115 set local variables in this object
121 load schema, if given
124 use default timezone?
128 ///////////////////////////// Table Management ///////////////////////////////////
160 make $this Databsae the column's Database
161 save this table with the table name as key
171 $this database is no longer the table's database
193 ///////////////////////////// LoadXmlSchema ///////////////////////////////////
207 if set to true, all tables currently loaded within this instance will be removed (unmanaged. the actual table still exists in the real db). if false, the given $xmlSchemaFilePath is simply added to whatever is currently in this database instance (tables/properties with the same name are overwritten with the new schema)
215 clear old tables... new database schema coming in.
220 default schema path
223 validate the xml with the schema
229 store schema's last mod time. Useful for serializing objects, storing them somewhere ($_SESSION, memcached, etc), then retrieving without needing to completely rebuild the database from xml
246 bs-"boolean string"
251 www.w3.org/2001/XMLSchema">'."\n";
282 only print if we need to
286 only set display name if it isnt the same as the column name
290 enum data type
294 non-enum data type
296 only print if we need to
297 only save PossibleValues to its own attribute if not an enum data type... otherwise, it's part of the data type
309 dont set a MaxSize for int with maxsize=1. this field doesn't matter anyway. it's for left-zero padding
312 dont set MaxSize for binary with maxsize=1. this is default for binary columns
315 dont set MaxSize for decimal with maxsize="14,4". this is default for binary columns
317 filters pass. print MaxSize
321 true is default, so only print if false
324 true is default, so only print if false
330 true is default, so only print if false
333 true is default, so only print if false
342 auto-increment shouldnt be required, otherwise we dont get the autoincrement value
354 "text" is default, so only print if something else
367 SortOrder not yet implemented
368 $xml .= ' SortOrder="'.$Column->SortOrder.'"';
377 handle related columns (ie foreign keys)
411 write xml to file?
426 database table/column structure
428 key is the table name, value is an array containing all inhertied table names. (ie key table inherits value tables)
440 track inherited tables. will handle adding inherited columns after all regular tables/column have been added
441 "InheritsTableName" attribute is old and deprecated. use the plural "InheritsTableNames" since it is supported now
443 $inheritsTableNames could be CSV of multiple table names
450 optimization. we'll manually call $table->Refresh() after all columns have been added
458 add column aliases
459 if the "Aliases" attribute exists..
460 convert CSV string into array or FALSE if it's an empty string (false will avoid the foreach loop)
468 enum data type
470 parse out the enum values
473 non-enum data type
475 add column possible values. if set and the data type is enum, these will be used as the only possible values instead of the enum values (ie you can use a subset of the possible values specified in the enum data type)
476 if the "PossibleValues" attribute exists..
477 convert CSV string into array or FALSE if it's an empty string
489 default value is true
490 default value is true
492 default value is true
493 default value is true
501 "text" is default value
502 auto-increment shouldnt be required, otherwise we dont get the autoincrement value
510 optimization by doing this manually instead of using $table->AutoRefresh
511 re-enable auto refresh
514 foreach($allXmlClasses
516 is_array($allXmlClasses)
518 related columns
524 compile all in this relation
530 set all in this relation
548 handle inherited tables
566 this table is already ready to go. move along
573 inherited table is not ready yet, build it first
600 libxml_use_internal_errors(true); //uncomment to show xml parse errors
605 tried to pull in default values from the XSD document (for "AllowSet", "AllowGet", etc). could never get it to work. instead, we just set those default values in the XML parser and in the SmartColumn class itself
606 if($xsdFilePath){
607 $reader->setSchema($xsdFilePath);
608 }
622 v=value)
625 a=attributes
642 when validating data, if any error is encountered, libxml will generate PHP Warnings,
643 which is something I think is very annoying. to avoid that, you can disable libxml errors
644 and get them yourself. remember! this function must be called before you instantiate any DomDocument object!
647 creating a DomDocument object
649 loading the xml data
651 tries to validade the file
653 get errors
654 each element of the array $allErrors will be a LibXmlError Object
661 ///////////////////////////// SyncDb ///////////////////////////////////
667 if true, prints all Sync SQL instead of executing it
668 if true, creates a backup table before altering any existing tables
669 if true, tables and columns will be created if they do not exist
670 if true, existing SQL columns will be updated to match properties defined in the SmartDatabase
671 if true, columns that do not exist on a SmartDb managed table will be removed (note: unmanaged TABLES are never deleted!)
679 default options
686 overwrite $defaultOptions with any $options specified
695 print_nice($syncStructure);
697 TODO: support other databases
700 parameters: DoSync($dbManager, $newDbStructure, $backupTables=true, $doInsert=true, $doUpdate=true, $doDelete=true, $debugMode=false)
710 abstract tables do not actually go in the database, but they can be inherited from
712 if table name was updated programmatically, we need this to be right in our sync structure
716 if column name was updated programmatically, we need this to be right in our sync structure
718 Field
721 Type
724 enum.. type
728 ..char.. type
732 ..int.. type
735 ..int.. primary key
739 ..binary.. type
743 ..decimal.. type
745 default precision
752 array, object types
753 use text for array/object types. we can make the size configurable somehow if we need to down the road
756 Null
761 Key
770 Fulltext index
774 Nonunique index
783 Default
786 Extra
791 Collation
796 TODO: get this hard-coded SQL out of here... move to Sync class for a MySQL database
800 all columns
809 forced character set
810 reference: http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html
822 no need for more yet. also may need to add a collation option
828 null
834 default value
835 blob/text types cant have default values in mysql
839 auto increment
844 primary key
850 unique
852 no need to specify as UNIQUE if it's a primary key. this will make 2 indexes
857 fulltext index
862 nonunique index
870 key columns
877 fulltext columns
882 nonunique columns
893 ///////////////////////////// ReadDatabase //////////////////////////////////
899 if true, the current smart database structure will be preserved. existing tables/column will be overwritten by the db definitions
900 will not import tables that start with the given prefix
901 string - if provided, will only read the structure of the given table name
907 default options
912 overwrite $defaultOptions with any $options specified
919 reset current database structure store in smartdb
924 TODO: support other databases
925 currently only works with PMA_MYSQL_INT_VERSION >= 50002
928 print_nice($sqlStructure);
932 ignoring this table due to prefix match
935 existing table (likely preserve-current option set to true)
938 new table (likely preserve-current option set to false)
942 optimization. we'll manually call $table->Refresh() after all columns have been added
944 track the column number
946 existing column (likely preserve-current option set to true)
949 new column (likely preserve-current option set to false)
954 $columnProps are the following:
955 int(1) unsigned
965 use datatype to determine each of the following vars:
973 find parenthesis in column type
974 $pos contains parenthesis position
975 ex type: "int(1) unsigned"
976 "int"
977 "(1) unsigned"
978 "(1)" - $unsigned will be 0 or 1
979 1
982 parse out the enum values
985 size just holds the possible values. dont keep it around
1000 these datatypes will never really be set in SQL, so this IF statement is pretty much worthless
1006 for debugging
1029 auto-increment shouldnt be required, otherwise we dont get the autoincrement value
1033 use the column name to come up with something display friendly
1059 replace hyphens and underscore with space
1060 upper case the first words and trim
1062 only set the display name if it's different from the column name, otherwise there's no need
1071 optimization by doing this manually instead of using $table->AutoRefresh
1072 re-enable auto refresh
1077 $smartStructure = $this->BuildSyncStructure(); //current structure of the smartdb
1078 print_nice($smartStructure);
1081 ///////////////////////////// ArrayAccess ///////////////////////////////////
1110 ///////////////////////////// Countable ///////////////////////////////////
1119 ///////////////////////////// ERROR ON INVALID FUNCTIONS/VARS //////////////////////////
1139 ////////////////////////////// STATIC - GET SmartDatabase OBJECT FROM MEMCACHED ////////////////////////////////
1143 options are same as SmartDatabase constructor, plus a few extra for memcached
1145 DbManager - The DbManager instance that will be used to perform operations on the actual database. If null, no database operations can be performed (use for 'in-memory' instances)
1146 string - REQUIRED for caching - the database schema file to load. If left null, you will need to either build the database yourself useing ->AddTable() or load a schema from XML using ->LoadSchema()
1147 if set, $SmartDb->DefaultTimezone will be set to this value
1148 boolean - development mode toggle. When true, does extra verifications (ie data types, columns, etc) that are a must for development, but may slow things down a bit when running in production.
1149 boolean. if true and in $DEV_MODE, warnings will be shown for like missing classes and etc.
1150 string. REQUIRED for caching. memcached lookup key
1151 string. memcached connection host
1152 int. memcached connection port
1153 int. failover fast-ish
1154 a much better serializer than the default one in PHP
1155 actually makes things faster too
1162 we'll make sure memcached exists before using it
1164 default options
1165 'db-manager' => null,
1166 'xml-schema-file-path' => null, //REQUIRED for caching to work properly!
1167 'default-timezone' => '' //if set, $SmartDb->DefaultTimezone will be set to this value
1170 REQUIRED for caching to work properly
1173 override default. make failover fast-ish
1174 a much better serializer than the default one in PHP
1175 actually makes things faster too
1177 overwrite $defaultOptions with any $options specified
1182 check for all required arguments
1189 check for cached smartdb
1193 set options
1198 try to get the key from cache
1201 log an error if we didn't get a key. we'll see a lot of these if the cache server is down
1216 check if cachedDb is found and valid
1218 compare XML dates on cached schema to make sure cache is not expired. also make sure we're using the same version of the SmartDatabase
1223 dates and smartdb version match. valid cached db
1224 update the db manager. this can't be cached
1226 timezone could change from what was cached
1231 set our global to the cached db
1235 if no valid cache db found. create a new smartdb and store it in cache
1238 update cache (if no errors trying to fetch from memcached earlier)
1247 end class
1254 capture the output of print_r
1257 replace something like '[element] => <newline> (' with <a href="javascript:toggleDisplay('...');">...</a><div id="..." style="display: none;">
1260 replace ')' on its own on a new line (surrounded by whitespace is ok) with '</div>
1263 print the javascript function toggleDisplay() and then the transformed output
TODO 67 fully implement this. already has some stuff in SmartCell and SmartRow

DbManagers/DbManager.php 4

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
42 utility functions
47 database management

DbManagers/DbManager_MySQL.php 227

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
22 Variables
31 encrypted. use $this->GetPassword();
34 default. see consts below
35 deprecated in PHP v5.5. not recommended
38 the PHP_INT_MAX constant doesnt work in some encrypters
46 should be "AND" or "OR" only
54 for mysqli driver, when false, persistent connections are used (recommended). for mysql driver, this is the 4th parameters for mysql_connect. see mysql_connect documentation
55 for mysql driver only- this is the 5th parameters for mysql_connect. see mysql_connect documentation
56 if set, OpenConnection does a mysql_set_charset() with the given option (ie 'utf8mb4'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
57 if set with charset, OpenConnection does a "SET NAMES..." with the given option (ie 'utf8mb4_unicode_ci'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
58 can be 'mysql' or 'mysqli' - the PHP extension to use for sql interaction. note- PHP v5.5+ deprecates 'mysql' driver
59 TODO: make default '+0:00'. empty will use system default time (not recommended). use hard numbers like '+0:00' cause timezone abbreviations must be defined in mysql otherwise, otherwise they may take no effect
66 for mysqli driver, when false, persistent connections are used (recommended). for mysql driver, this is the 4th parameters for mysql_connect. see mysql_connect documentation
67 for mysql driver only- this is the 5th parameters for mysql_connect. see mysql_connect documentation
68 if set, OpenConnection does a mysqli_set_charset() with the given option (ie 'utf8mb4'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
69 if set with charset, OpenConnection does a "SET NAMES..." with the given option (ie 'utf8mb4_unicode_ci'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
70 can be 'mysql' or 'mysqli' - the PHP extension to use for sql interaction. note- PHP v5.5+ deprecates 'mysql' driver
71 TODO: make default '+0:00'. empty will use system default time (not recommended). use hard numbers like '+0:00' cause timezone abbreviations must be defined in mysql otherwise, otherwise they may take no effect
79 SEE self::$DefaultOptions
80 this is the 4th parameters for mysql_connect. see mysql_connect documentation
81 this is the 5th parameters for mysql_connect. see mysql_connect documentation
82 if set, OpenConnection does a mysql_set_charset() with the given option (ie 'utf8mb4'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
83 if set with charset, OpenConnection does a "SET NAMES..." with the given option (ie 'utf8mb4_unicode_ci'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
84 can be 'mysql' or 'mysqli' - the PHP extension to use for sql interaction
85 recommended this is set to '+0:00'. empty will use system default time (not recommended). use hard numbers like '+0:00' cause timezone abbreviations must be defined in mysql otherwise, otherwise they may take no effect
101 merge in options
102 merge passed options with DefaultOptions
107 set the db driver from options (mysql or mysqli)
111 the rest of the options are our connection params
127 default
149 query MySQL to set client charset & collation. ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
166 $this->_server.$this->_user will be our encrypt key
174 $this->_server.$this->_user will be our encrypt key
183 doesn't do a mysql_select_db. good for creating databases and etc management
196 -- mysql
200 -- mysqli
201 "new link" is created by default with mysqli
202 persistent connections are special (to help avoid max_user_connections
203 see http://php.net/manual/en/mysqli.persistconns.php - "To open a persistent connection you must prepend p: to the hostname when connecting."
205 store active 'links' for each server/username combination for reuse
208 no connection yet, create one and cache in static links array
211 connect to database using cached link
223 see if a charset is set (ie "utf8mb4");
226 get options
230 -- mysql
231 set PHP driver charset
234 query MySQL to set client charset & collation. ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
239 -- mysqli
240 set PHP driver charset
243 query MySQL to set client charset & collation. ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
262 exception show's the password passed through the constructor. only use for debugging
264 die("Bad arguments for DbManager constructor. Msg: ".$e->getMessage());
277 -- mysql
280 -- mysqli
293 if true, will immediately call mysql_select_db() with the database passed to this class
322 -- mysql
325 -- mysqli
339 if true, does a SELECT DISTINCT for the select. Note: there must only be 1 select field, otherwise an exception is thrown
341 if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
342 if true, automatically adds `quotes` around the `column names` in select fields
343 if true, automatically adds `quotes` around the `column names` in the where clause
344 if true, automatically adds `quotes` around the `column names` in the order clause
346 if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
347 if true, automatically adds dot.notation before column names in select fields
348 if true, automatically adds dot.notation before column names in the where clause
349 if true, automatically adds dot.notation before column names in the order clause
351 if true, numerics will always be quoted in the where clause (ie "WHERE `price`='123'" instead of "WHERE `price`=123"). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
352 if true, will always call mysql_select_db() with the database passed to this class
371 default to "SELECT * ..."
387 extended options
391 should handle $limit==0, which is invalid.
392 matches "10" or "100,10". will incorrectly match "0", but "0,10" is correct. the if statement above should handle the "0" case though
409 if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
410 if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
411 if true, will call mysql_select_db() with the database passed to this class
429 Compile SQL fields
432 save column name without quotes or dot notation
438 Compile SQL values
441 now()
462 if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
463 if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
464 if true, will call mysql_select_db() with the database passed to this class
465 if true, numerics will always be quoted in the where clause (ie ...WHERE `price`='123'... instead of ... WHERE `price`=123...). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
486 save column name without quotes or dot notation
494 now()
505 extended options
525 if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
526 if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
527 if true, will call mysql_select_db() with the database passed to this class
528 if true, numerics will always be quoted in the where clause (ie ...WHERE `price`='123'... instead of ... WHERE `price`=123...). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
545 extended options
565 set to true if writing a query without dot notation (database.table.field) AND your app uses multiple databases with 1 connection (ie not using the 'new_link' flag on any database connection)
566 if true, will skip any call to mysql_select_db. good for creating databases and etc management
567 (NOT SUPPORTED WITH DRIVER 'mysql') - if true, will use mysqli_multi_query. use NextResult() to iterate through each query's result set. throws an exception on error
585 reset vars
591 lazy connect
593 the reason for this else: if we just connected, database was just selected. no need to select it again here.
597 -- mysql
598 NOT SUPPORTED with mysql
603 -- mysqli
612 if last_result is false and there is no error, this could have been an insert. this is valid
618 var_dump($query);
619 var_dump($this->_connection);
621 var_dump($this->_lastResult);
639 -- mysql //NOT SUPPORTED with mysql
642 -- mysqli
645 no more results
653 if last_result is false and there is no error, this could have been an insert. this is valid
663 php.net/manual/en/mysqli.multi-query.php
669 -- mysql //NOT SUPPORTED with mysql
670 throw new Exception("NextResult(), FlushResults(), and 'multi-query' are not supported with driver 'mysql' (use mysqli)");
673 -- mysqli
684 -- mysql
687 -- mysqli
726 so an empty array is returned if no rows are set. avoids "Warning: Invalid argument supplied for foreach()"
765 so an empty array is returned if no rows are set. avoids "Warning: Invalid argument supplied for foreach()"
798 -- mysql
801 -- mysqli
828 -- mysql
831 -- mysqli
846 -- mysql
849 -- mysqli
861 -- mysql
864 -- mysqli
876 -- mysql
879 -- mysqli
896 -- mysql
899 -- mysqli
911 TODO: get rid of this completely and disable magic quotes: http://www.php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc
912 if (get_magic_quotes_gpc()) { //DEPRECATED! will be removed in PHP 6
913 $string = stripslashes($string);
914 }
918 -- mysql
921 -- mysqli
941 $direction is actually the col name them because user input array like array("id","col1"); assume asc for cols
947 else $colName = $colName;
970 clean up val
973 yes dot notation
974 no dot notation, but yes column quotes
975 no dot notation or column quotes
989 get table name. if $table is not a string, it has to be a SmartTable object
1009 if true, numerics will always be quoted in the where clause (ie ...WHERE `price`='123'... instead of ... WHERE `price`=123...). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
1026 need to add an " AND " (or " OR ") in between clauses. see constructor options
1028 force "AND" or "OR"
1056 check if key is a condition
1059 check if key is an operator
1062 if the key is not a keyword and not numeric, it is assumed to be the column name
1066 the value returned
1067 $val can either be a scalar or an array
1068 value is an array, recurse.
1072 need to add an " AND " or " OR " in between clauses
1078 wrap in parenthesis
1080 $val is a scalar. this is the end of the recursion
1099 the value returned
1100 clean up field name
1104 save column name without quotes or dot notation
1108 else $column = $column;
1111 null is special
1113 'is not null' for null
1115 'is null' for null
1117 value is not null
1118 SPECIAL CASES FOR "LIKE" CONDITION
1119 See: http://stackoverflow.com/questions/3683746/escaping-mysql-wild-cards
1121 to make sure we don't over-escape single quotes, we'll escape single quotes as "''" instead of "\'"
1122 underscore ('_') is a wildcard in LIKE matching one character. need to escape it to match the actual underscore
1123 see http://dev.mysql.com/doc/refman/5.1/en/string-literals.html
1126 "To search for "\", specify it as "\\\\"; this is because the backslashes are stripped once by the
1127 parser and again when the pattern match is made, leaving a single backslash to be matched against."
1128 see http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
1135 HACK-ish: MySQL doesn't recognize NULL as '!=' some value. we have to force null checking.
1166 match operator
1167 match condition
1168 no match
1181 operators
1186 no match
1200 conditions
1211 special conditions
1213 special conditions
1216 no match
1224 for reverse compatibility. only used if $table is a string and not a SmartTable object
1235 default options
1237 overwrite $defaultOptions with any $options specified
1243 HACKish - handle SmartCells in case someone accidentally forgets to call ->GetValue() on the smart cell
1248 null is null
1253 if $table is not a string, it has to be a SmartTable object. we can use this to get the column type
1256 handle booleans.
1258 boolean false is '\0'. make booleans default to 1 and 0
1263 get the column's data type to determine if the value should be quoted
1265 $table is a SmartTable object
1267 dont quote numbers
1284 needs quotes. this data type stores binary strings that have no character set or collation (it is NOT strictly ones and zeros)
1285 force binary to be 0 if nothing is set
1289 quote non-numbers
1291 false should evalute to empty string
1298 notify us of the invalid column and table, but don't error out
1299 trigger_error($e->getMessage(), E_USER_WARNING );
1304 if we get here, we dont have database structure info and need to try to best guess how quotes should be used (also for reverse compatibility)
1305 note that the following will incorrectly not quote something like "053" or even "546t" for varchar fields, and 53 or 546 get used instead.
1306 this is why a SmartDb is recommended for db structure info
1359 table doesn't exist to drop
1366 table still exists
1367 table doesn't exist anymore
1379 table doesn't exist to drop
1396 database already exists
1405 database wasn't created
1406 database created
1416 database doesn't exist to drop
1425 database still exists
1426 database doesn't exist anymore
1447 default options
1454 overwrite $defaultOptions with any $options specified
1459 make sure the source database exists
1464 drop the destination database if it already exists and $options['drop-existing-database']==true
1470 create the destination database if it doesnt already exist
1476 set our dbmanager to the $sourceDatabaseName so we can select the tables/data
1477 we'll restore this after the copy operation
1480 need to restore the database connection if something fails
1481 get all table records in the source database
1485 loop through all source table records
1489 copy the structure of the table
1499 copy the data with primary keys and indexes and etc
1505 restore the database connection if something goes wrong
1510 restore the database connection
1652 ********************* password management ********************************
1664 pad with null characters

SmartTable.php 204

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
23 ///////////////////////////// SERIALIZATION - At top so we don't forget to update these when we add new vars //////////////////////////
50 ////////////////////////////////////////////////////////////////////////////////////
72 default to false
90 ///////////////////////////// Table Structure ///////////////////////////////////
91 Key is the column name, Value is the Column instance.
92 Key is the column alias name, value is the actual column name
94 computed from $this->_columns
95 computed from $this->_columns
96 computed from $this->_columns
97 computed from $this->_columns
99 key is the function name, value is the DbManager results to cache
222 clear column aliases
239 handle columns with aliases
257 a little error checking to make sure the structure checks out
262 ///////////////////////////// Column Management ///////////////////////////////////
274 make $this table the column's table
275 save this column with the column name as key
289 the actual column exists
292 a column alias exists
311 $this table is no longer the column's table
326 ///////////////////////////// Table Inheritance ///////////////////////////////////
358 already inherited
363 clone so when AddColumn() changes the Table of the Column, it doesnt affect the original Column's Table reference
364 false so we don't replace existing columns. Need this for table inheritance since the regular columns are added first, then the inherited columns. dont want to replace a regular column wiht an inherited one
366 inherit relations from $Column
368 this column has relations
369 add a relation between this table and the original table
371 add relation between this table and the inherited columns that were set from the original table
380 ///////////////////////////// Invoke ///////////////////////////////////
396 ///////////////////////////// ArrayAccess ///////////////////////////////////
425 ///////////////////////////// Countable ///////////////////////////////////
436 ///////////////////////////// Table Data Functions ///////////////////////////////////
438 used internally to track max depth of the lookupAssoc in VerifyLookupAssoc()
448 INTERNAL GLOBAL! this is determined within VerifyLookupAssocHelper
459 This extra array wrapping can be ignored once we are sure the DbManager will always AND by default for multi-elements within the first dimension of lookup arrays
460 not a multi-dimension array... wrap another array around this one so we AND by default instead of OR (as the DbManager does for backwards compatibility)
461 extra array needed for the backwards compatibility within DbManager
472 track array's depth internally
475 verify $key is numeric, a column name, or a keyword (ie "AND", "OR", "<", "!=", etc)
476 not numeric or a keyword. must be a column
479 check aliases
481 gets the real column name in case the $key is a column alias
482 if these are different, we have a column alias
483 transfer alias lookup settings to the actual column
485 unset alias
489 recurse?
495 the actual lookup value. normalize data, based on column data type
497 don't convert serialized objects/arrays so we can do raw string comparisons
508 check that the 'return-next-row' option is set
510 option not not set
513 verify the 'return-next-row' option is passed by reference. it MUST be
516 copy options array and test if the 'return-next-row' is passed by reference
519 not passed by reference
523 'return-next-row' is passed by reference.
524 restore the original return-next-row option.
525 make sure the original is an int
526 if $curVal is >0 here, then we're returning the NEXT row and should have a cached dbmanager to use
527 no cached dbmanager? assume this is the first call and we should return the first row of the result set
540 Either a string of the column to sort ASC by, or an assoc array of "ColumnName"=>"ASC"|"DESC" to sort by. An exception will be thrown if a column does not exist.
541 function - if set, this function will be invoked for each row and the full result set will NOT be returned- only the LAST ROW in the set will be returned (if there is one). the function's signature should be function($row, $i){} where $row is the actual SmartRow, and $i is the 1-based index of the row being returned
542 if true, the returned assoc-array will have the row's primary key column value as its key (if a non-composite primary key exists on the table. otherwise this option is ignored) and the Row instance as its value. ie array("2"=>$row,...) instead of just array($row,...);
543 OUT variable. integer. if you set this parameter in the $options array, then this function will return only 1 row of the result set at a time. If there are no rows selected or left to iterate over, null is returned.
544 THIS PARAMETER MUST BE PASSED BY REFERENCE - i.e. array( "return-next-row" => &$curCount ) - the incoming value of this parameter doesn't matter and will be overwritten)
545 After this function is executed, this OUT variable will be set with the number of rows that have been returned thus far.
546 Each consecutive call to this function with the 'return-next-row' option set will return the next row in the result set, and also increment the 'return-next-row' variable to the number of rows that have been returned thus far
547 With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set
548 With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
549 OUT variable only. integer. after this function is executed, this variable will be set with the number of rows being returned. Usage ex: array('return-count'=>&$count)
550 if true, the return-count will be returned instead of the rows. A good optimization if you dont need to read any data from the rows and just need the rowcount of the search
563 table must have a single primary key column
568 get DbManager we need to use. could be a stored result set if $returnNextRow > 0
572 check for the 'return-next-row' option to return 1 row at a time
573 returns INT >= 0 or FALSE
575 check the 'callback' option
578 verify we have an anonymous function or a function name in global scope
582 do the query if we're not returning the next row from our result set
583 spelling out both cases for clarity - $returnNextRow could be 0 or false here. both should run the new query
584 clear any cached result sets we may have
589 $lookupAssoc is not required. if no $lookupAssoc is given, this will be identical to GetAllRows().
594 do the new query
600 check the 'return-count-only' option
604 fetch SQL results
605 specifically check for FALSE here (zero is valid for returning the 1st row of the set)
606 if we're returning the first row of a result set, we need to store this particular result dbmanager to iterate over later, so clone our current DbManager and save it to this Table object
611 return just a single result at a time from the stored DbManager's result set
612 just 1 row.
613 no more rows to fetch in this result set
615 track the number of records we've returned
617 take SQL results and return SmartRows
620 callback?
622 call the user's function
632 if we're returning one row at a time, we need to store this particular result dbmanager to iterate over later, so clone our current DbManager and save it to this Table object
635 get row
639 call the user's function
643 clear cached result sets we may have
644 clear any cached result sets we may have
651 'return-next-row' option is not set. return array of all results
652 get an array of all of the rows
654 take SQL results and return SmartRows
661 take SQL results and return SmartRows
664 specifically check for FALSE here (zero is valid for returning the 1st row of the set)
665 return only a single row at a time
668 return all rows as an assoc array with row-key as array-key
673 return all rows pushed onto an array
683 specifically check for FALSE here (zero is valid for returning the 1st row of the set)
684 return only a single row at a time
687 return all rows as an assoc array with row-key as array-key
692 return all rows pushed onto an array
714 handle $lookupVals as a non-array... only works if column is a non-composite primary key
715 NON-ARRAY. special case where $lookupVals is just the key column value
727 table must have a single primary key column
739 match
751 no match. return a new instance with this value set.
762 try to set the column values to what was looked up since the row was not found
763 force disable commit changes immediately in this case
767 filter column names in the lookup assoc
773 set values on the row to be returned
781 set commit changes immediately back to its old value
801 if the key is not a keyword and not numeric, it is assumed to be the column name
803 check if key is a condition
807 check if key is an operator
811 if the key is not a keyword and not numeric, it is assumed to be the column name
815 $val can either be a scalar or an array
816 value is an array, recurse.
821 $val is a scalar. this is the end of the recursion
822 clean up field name
825 only track columns with an '=' condition and columns that are not defined multiple times
830 hopefully this is unique enough :)
835 on final pass, remove any ___ignore___ columns
847 Either a string of the column to sort ASC by, or an assoc array of "ColumnName"=>"ASC"|"DESC" to sort by. An exception will be thrown if a column does not exist.
848 If true, only unique values will be returned. Note: array keys in the returned array will NOT be the key column when this is true)
849 if true, the returned assoc-array will have the row's primary key column value as its key (if a non-composite primary key exists on the table. otherwise this option is ignored) and the $returnColumn's value as its value. ie array("2"=>$returnColumnValue,...) instead of just array($returnColumnValue,...);
850 With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set
851 With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
852 OUT variable only. integer. after this function is executed, this variable will be set with the number of values being returned. Usage ex: array('return-count'=>&$count)
853 if true, the return-count will be returned instead of the rows. A good optimization if you dont need to read any data from the rows and just need the rowcount of the search
862 reverse-compatibility: $lookupAssoc used to be first parameter, then $returnColumn was second. handle both situations
863 if this is true "$returnColumn" is actually "$lookupAssoc" (reverse compatibility). need to swap these parameters
864 tmp store the actual $returnColumn (in $lookupAssoc) so we can overwrite $lookupAssoc
865 overwrite $lookupAssoc to be the actual lookup array
866 overwrite $returnColumn with the actual column
871 column may be an alias and/or may need to unserialize the returned data. get the actual column and check if it's serialized
873 override $returnColumn name. handles aliases
876 $lookupAssoc is not required. if no $lookupAssoc is given, this will work similar to SmartColumn->GetAllValues().
888 table must have a single primary key column
895 check the 'return-count-only' option
898 return an assoc array
901 depending on the column's data type, we may need to normalize the raw database value for everyday use
905 return a regular array
908 depending on the column's data type, we may need to normalize the raw database value for everyday use
913 no primary key or returning UNIQUE results only
917 check the 'return-count-only' option
922 depending on the column's data type, we may need to normalize the raw database value for everyday use
938 row not found
953 If true, all row-level "Delete" callbacks will be skipped. This can substantially improve the performance of very large bulk deletions.
967 skipping delete callbacks on the row-level will delete rows directly on the DB level for efficiency
968 yes, skip callbacks. faster.
969 handle $lookupAssoc as a non-array... only works if column is a non-composite primary key
970 NON-ARRAY. special case where $lookupAssoc is just the key column value
980 make sure we're only looking up with key/unique columns
995 dont skip callbacks. need to lookup the row and delete the row directly. slower than the above
997 1 row deleted
998 0 rows deleted
1008 If true, all row-level "Delete" callbacks will be skipped. This can substantially improve the performance of very large bulk deletions.
1020 skipping delete callbacks on the row-level will delete rows directly on the DB level for efficiency
1021 yes, skip callbacks. faster.
1028 dont skip callbacks. need to lookup each row and delete each row directly. slower than the above
1031 delete row and increase count if successful
1044 If true, all row-level "Delete" callbacks will be skipped. This can substantially improve the performance of very large bulk deletions.
1055 skipping delete callbacks on the row-level will delete rows directly on the DB level for efficiency
1056 yes, skip callbacks. faster.
1061 dont skip callbacks. need to lookup each row and delete each row directly. slower than the above
1064 delete row and increase count if successful
1076 Either a string of the column to sort ASC by, or an assoc array of "ColumnName"=>"ASC"|"DESC" to sort by. An exception will be thrown if a column does not exist.
1077 function - if set, this function will be invoked for each row and the full result set will NOT be returned- only the LAST ROW in the set will be returned (if there is one). the function's signature should be function($row, $i){} where $row is the actual SmartRow, and $i is the 1-based index of the row being returned
1078 if true, the returned assoc-array will have the row's primary key column value as its key and the row as its value. ie array("2"=>$row,...) instead of just array($row,...);
1079 OUT variable. integer. if you set this parameter in the $options array, then this function will return only 1 row of the result set at a time. If there are no rows selected or left to iterate over, null is returned.
1080 THIS PARAMETER MUST BE PASSED BY REFERENCE - i.e. array( "return-next-row" => &$curCount ) - the incoming value of this parameter doesn't matter and will be overwritten)
1081 After this function is executed, this OUT variable will be set with the number of rows that have been returned thus far.
1082 Each consecutive call to this function with the 'return-next-row' option set will return the next row in the result set, and also increment the 'return-next-row' variable to the number of rows that have been returned thus far
1083 With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set
1084 With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
1085 OUT variable only. integer. after this function is executed, this variable will be set with the number of rows being returned. Usage ex: array('return-count'=>&$count)
1086 if true, the return-count will be returned instead of the rows. A good optimization if you dont need to read any data from the rows and just need the rowcount of the search
1117 //////////////////////// PRIVATE HELPER CLASSES //////////////////////////
1128 $key is column name. 'asc' or 'desc' is the $val
1132 default
1135 $val is column name ($key is nothing). default to 'asc'
1137 default
1140 column exists
1141 column may be an alias. get the actual column name
1143 override $sortBy name with actual name
1145 set final sort val
1153 use a string as a single column name to sort by
1155 default for a single string column
1156 column exists. default to ASC
1157 column may be an alias. get the actual column name
1159 override $sortBy name with actual name
1161 set final sort val
1172 ///////////////////////////// ERROR ON INVALID FUNCTIONS/VARS //////////////////////////
1194 end class
TODO 1095 Make all tables work with this function

SmartRow.php 170

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
31 implement custom functionality using $this
33 ---------- START EXAMPLE CUSTOM FUNCTIONALITY ------------//
34 formats an alpha-numeric "Price" column
35 if we have any alpha characters, return the price as is. otherwise, we'll format it up (i.e. could return "$12.43" or "CALL FOR PRICE")
37 $this is the current SmartRow instance, containing our row data for/from the database
46 helper function - turns something like "$12,300.50" or "$12300.50" or "12300.50" into "12300.5", which can then be formatted exactly as needed.
50 ---------- END EXAMPLE CUSTOM FUNCTIONALITY ------------//
58 There are 2 signatures for this (which allows for extending on this class, but using a different table)
59 1. __construct($Database, $keyColumnValues=null, $options=null) //uses table "YOUR_TABLE_NAME"
60 2. __construct($tableName, $Database, $keyColumnValues=null, $options=null) //uses table $tableName
65 implement custom functionality using $this
79 ///////////////////////////// SERIALIZATION - At top so we don't forget to update these when we add new vars //////////////////////////
109 ////////////////////////////////////////////////////////////////////////////////////
126 Key is the column name, value is the Cell instance.
128 true when changes need to be committed to the database
129 true when this instance represents a row that exists in the database; false if this row is not yet in the database
130 true if initial column values have been pulled from the database (if the row exist in the database. if it does not, this bool will be false)
146 if set to false, the default values will not be set on any Cell of the new row
159 save the Database
160 save the dbManager for easy access
163 initialize all Cells of this row
168 this column has a default value
173 handle $keyColumnValues that may have been passed through
175 ARRAY
183 1 NON-ARRAY
247 no exception on error
257 If true: does not validate the key columns. If false: validates all columns
258 If true: only cells that have been set (i.e. isset()==true) will be verified (not recommended if this info will be committed to db). If false: all cells will be verified (should be used if this info will be committed to db).
259 appended to each error message
267 default options
270 overwrite $defaultOptions with any $options specified
287 If true: does not validate the key columns. If false: validates all columns
288 If true: only cells that have been set (i.e. isset()==true) will be verified (not recommended if this info will be committed to db). If false: all cells will be verified (should be used if this info will be committed to db).
320 the actual column exists
325 a column alias exists
396 true if changes have been made to the key from what was previously defined before calling this function
399 only working with NON auto-increment key columns
402 get the passed value... either with the real column name or the first found alias (ignores multiple matches)
405 compare the passed key value to the current key value
413 only working with NON auto-increment key columns
419 check if this new key already exists in database
420 build the where clause array
422 only working with NON auto-increment key columns
423 get the passed value... either with the real column name or the first found alias (ignores multiple matches)
433 a row with this key already exists
437 delete old row from database with old key from before calling this method
441 set new key columns
442 only working with NON auto-increment key columns
445 get the passed value... either with the real column name or the first found alias (ignores multiple matches)
454 automatically commit changes now?
467 get the passed value... either with the real column name or first found alias (ignores multiple matches)
468 real column name
471 check aliased columns
477 real column name
499 info must be setup as $assocArray = array('TableName'=>array('ColumnName1'=>value, ...))
503 check real columns
509 real columns
512 real column notifier
513 notifier let us know this column was in use on the page, but as a checkbox, its POST does not get sent if the checkbox is not checked. so set the 'not checked' value
515 check column alias only as a last resort if the real column name was not found
518 aliased column
521 aliased column notifier
522 notifier let us know this column was in use on the page, but as a checkbox, its POST does not get sent if the checkbox is not checked. so set the 'not checked' value
554 for reverse compatibility. the $options variable used to be a variable for $onlyAddSetColumns. false by default.
571 for reverse compatibility. the $options variable used to be a variable for $onlyAddSetColumns. false by default.
588 If false, populates the provided assoc-array with ALL get-able key columns. If true, populates the provided assoc-array with only the get-able columns that have been set (i.e. isset()==true)
589 if true, key columns are returned in the array. if false, key columns are not returned in the array
590 if true, non-key columns are returned in the array. if false, non-key columns are not returned in the array
591 set this to auto-format date columns. ref formarts that work with php's date() function (http://php.net/date)
599 for reverse compatibility. the $options variable used to be a variable for $onlyAddSetColumns. false by default.
603 default options
606 set this to auto-format date columns. ref formarts that work with php's date() function (http://php.net/date)
608 overwrite $defaultOptions with any $options specified
618 ignore key columns
619 ignore non-key columns
621 normalize dates?
623 true so value goes through strtotime()
624 strtotime could have failed to parse for some reason
625 using "date()" instead of "gmdate()" will return timestamp in whatever LOCAL time in, so be sure to include a timezone indicator in the date format
631 do not normalize dates
647 Either a string of the column to sort ASC by, or an assoc array of "ColumnName"=>"ASC"|"DESC" to sort by. An exception will be thrown if a column does not exist.
648 With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set
649 With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
650 OUT variable only. integer. after this function is executed, this variable will be set with the number of values being returned. Usage ex: array('return-count'=>&$count)
651 if true, the return-count will be returned instead of the rows. A good optimization if you dont need to read any data from the rows and just need the rowcount of the search
683 1 row found
686 check if the 1 found row has the same key as $this row
695 different row. update this $row with the data from the database
708 check the 'return-count-only' option
713 num or rows selected != 1
714 check the 'return-count-only' option
732 get the extended version of the class if exists
735 the extended version doesnt exist or is not in scope, so just return the Base class
745 ///////////////////////////// The Major Row-To-Database Communications ///////////////////////////////////
755 this row/table has no key columns, so nothing to look up
759 some sort of primary key exists
760 make sure every primary key is set. if not, do not query the database
762 if key is not set, don't lookup row
766 primary key is not yet set in this row/table, so nothing is in the database to get.
773 primary key is set in this row/table, so get the record from the database that matches this primary key
782 successfully got matching row from database table
789 value coming out of DB does not have timezone by default. it will assume LOCAL time unless specified.
798 matching row not found in database table
799 primary key is auto-increment
806 primary key is not auto-increment
829 row is not in database yet. insert a new row
830 event could be cancelled. make sure this is 0 at this point for our return value
834 returns number of rows inserted. should be 1 on success, 0 on fail (or TRUE/FALSE)
840 row exists in database. Update it
841 nothing to commit
843 event could be cancelled. make sure this is 0 at this point for our return value
862 all changes have been written to database. not dirty anymore
877 build arrays
908 error inserting new column into database
911 todo: handle this nicely?
914 successfuly inserted column. set the new column unique key value
917 primary key now has an id that was chosen by auto_increment in database
920 no primary key or primary key exists and is composite or non-autoincrement
921 todo: handle this nicely?
935 only delete if a key column is defined
938 not initialized yet. need to initialize to see if this row exists in database
939 row does not exist to delete
963 if 0 rows deleted, row still exists in database. this typically should not happen
964 if the row still exists in the database, the isDirty status will not have changed. otherwise the row doesnt exist, so not dirty
966 clear the values of auto-increment key columns
977 ///////////////////////////// ArrayAccess ///////////////////////////////////
1015 ///////////////////////////// JsonSerializable ///////////////////////////////////
1025 ///////////////////////////// TO STRING ///////////////////////////////////
1080 $str .= $this->InputValidation->ToString();
1084 //////////////////////////// INTERNAL CALLBACKS //////////////////////////////
1093 automatically commit changes now?
1096 ///////////////////////////// PUBLIC CALLBACKS ///////////////////////////////////
1128 row callback arrays
1129 callbacks to be fired before the row has been committed to database (can be insert or update)
1130 callbacks to be fired after the row has been committed to database (can be insert or update)
1131 callbacks to be fired before the has been insertted to database (doesnt include update)
1132 callbacks to be fired after the row has been insertted to database (doesnt include update)
1133 callbacks to be fired before the row has been updated to database (doesnt include insert)
1134 callbacks to be fired after the row has been updated to database (doesnt include insert)
1135 callbacks to be fired before the row has been deleted from database
1136 callbacks to be fired after the row has been deleted from database
1138 callbacks to be fired before any Cell of this row has been set
1139 callbacks to be fired before any Cell of this row has been set
1140 callbacks to be fired after any Cell of this row has been set
1148 no callbacks defined or callbacks disabled
1151 pass $this->Row reference back through to the callback
1165 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
1209 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
1253 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
1297 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
1334 /////// Cell callbacks /////////
1371 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
1372 the Cell that fired the event (Cell's contain all Column functionality and properties)
1373 the current value of this column, BEFORE it has changed to 'new-value'
1374 the value that this column is going to be set to, replacing the 'current-value'
1389 verify we have an anonymous function or a function name in global scope
1417 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
1418 the Cell that fired the event
1419 the current value of this column, BEFORE it has changed to 'new-value'
1420 the value that this column is going to be set to, replacing the 'current-value'
1435 verify we have an anonymous function or a function name in global scope
1462 the Cell that fired the event
1463 the current value of this column, AFTER it has been changed from 'old-value'
1464 the value that this column was set to before it was updated with the 'current-value'
1479 verify we have an anonymous function or a function name in global scope
1498 ///////////////////////////// ERROR ON INVALID FUNCTIONS/VARS //////////////////////////
1521 end class
TODO 753 add comments that explain what happens if no primary key exists

SmartColumn.php 120

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
19 ///////////////////////////// SERIALIZATION - At top so we don't forget to update these when we add new vars //////////////////////////
61 ////////////////////////////////////////////////////////////////////////////////////
133 MaxSize is something like (14,4) for decimals. first number is precision, second number is scale
135 add 1 for a decimal point
234 ///////////////////////////// Column Relations ///////////////////////////////////
263 set relation on $this column
266 set relation on related column
289 unset relation on related column
310 make sure $columnName isnt an alias
311 gets the real name of the column if $columnName is an alias
316 ///////////////////////////// Column Aliases ///////////////////////////////////
328 if true, the returned array will just be an array of alias names
352 set relation on $this column
386 ///////////////////////////// Column Data Functions ///////////////////////////////////
399 may need to transform the value to it's original type for array and object types
404 is a date column
413 is a date column
415 check for a default timezone
416 if value is set...
417 column level defaults take precedence over database level, if both defaults are set.
420 always stored as UTC when timezone in use
421 convert to that timezone
434 Either a string of the column to sort ASC by, or an assoc array of "ColumnName"=>"ASC"|"DESC" to sort by. An exception will be thrown if a column does not exist.
435 If true, only unique values will be returned. Note: array keys in the returned array will NOT be the key column when this is true)
436 if true, the returned assoc-array will have the row's primary key column value as its key and the row as its value. ie array("2"=>$row,...) instead of just array($row,...);
437 With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set
438 With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
439 OUT variable only. integer. after this function is executed, this variable will be set with the number of values being returned. Usage ex: array('return-count'=>&$count)
440 if true, the return-count will be returned instead of the rows. A good optimization if you dont need to read any data from the rows and just need the rowcount of the search.
486 MySQL reference - http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html
499 make sure lookup assoc is valid, if given
506 todo- move aggregate functions to DbManager somehow
514 may need to normalize the raw data for use. depends on the column's data type (mostly dates, in this case)
527 Either a string of the column to sort ASC by, or an assoc array of "ColumnName"=>"ASC"|"DESC" to sort by. An exception will be thrown if a column does not exist.
528 if true, the returned assoc-array will have the row's primary key column value as its key and the row as its value. ie array("2"=>$row,...) instead of just array($row,...);
529 function - if set, this function will be invoked for each row and the full result set will NOT be returned- only the LAST ROW in the set will be returned (if there is one). the function's signature should be function($row, $i){} where $row is the actual SmartRow, and $i is the 1-based index of the row being returned
530 OUT variable. integer. if you set this parameter in the $options array, then this function will return only 1 row of the result set at a time. If there are no rows selected or left to iterate over, null is returned.
531 THIS PARAMETER MUST BE PASSED BY REFERENCE - i.e. array( "return-next-row" => &$curCount ) - the incoming value of this parameter doesn't matter and will be overwritten)
532 After this function is executed, this OUT variable will be set with the number of rows that have been returned thus far.
533 Each consecutive call to this function with the 'return-next-row' option set will return the next row in the result set, and also increment the 'return-next-row' variable to the number of rows that have been returned thus far
534 With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set
535 With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
536 OUT variable only. integer. after this function is executed, this variable will be set with the number of rows being returned. Usage ex: array('return-count'=>&$count)
537 if true, the return-count will be returned instead of the rows. A good optimization if you dont need to read any data from the rows and just need the rowcount of the search.
547 normalize serialized data
573 normalize serialized data
594 If true, all row-level "Delete" callbacks will be skipped. This can substantially improve the performance of very large bulk deletions.
602 skipping delete callbacks on the row-level will delete rows directly on the DB level for efficiency
603 yes, skip callbacks. faster.
607 normalize serialized data
612 dont skip callbacks. need to lookup each row and delete each row directly. slower than the above
615 delete row and increase count if successful
636 If true, all row-level callbacks AND error-checking will be skipped. This can substantially improve the performance on very large tables.
637 Only available in conjunction with 'skip-callbacks'=true. If both of these options are true, all row-level error checking will be skipped when each updated Row is Commit()'ed.
647 skipping callbacks on the row-level will update rows directly on the DB level for efficiency
648 yes, skip callbacks. faster.
652 normalize serialized data
657 dont skip callbacks. need to lookup each row and update each row directly. slower than the above
661 update row and increase count if successful
662 note: this will call VerifyValueType(), so no need to here.
670 ///////////////////////////// Data Normalization ///////////////////////////////////
676 If true, serialized data will be left as-is (i.e. for using strings in lookup assocs)
685 handle special type conversions
686 development mode
687 convert objects to strings if the column type is not an object
703 production mode
704 convert objects to strings if the column type is not an object
709 null is null. let it go
712 handle booleans.
714 boolean false is '\0'. make booleans default to 1 and 0
719 handle date columns
720 can be a string of a date format or an int timestamp value since 1970
722 value is set. if a timezone is in use, use gmdate(). otherwise use date()
723 "date" DataType has a slightly different format than other DateColumns
727 column level defaults take precedence over database level, if both defaults are set.
729 a timezone is in use, always store a gmdate (not system time)
730 if value is int and < 100000000, we'll assume it's not a raw timestamp (100000000 puts us in 1970s somewhere)
732 strtotime( <int> ) returns false. if <int> data type, we assume $value is the raw timestamp value we should use, and skip strtotime
735 try to parse string. might return false if invalid
737 invalid date format
741 parsed successfully
746 no timezone in use, use date (system time)
747 if value is int and < 100000000, we'll assume it's not a raw timestamp (100000000 puts us in 1970s somewhere)
749 strtotime( <int> ) returns false. if <int> data type, we assume $value is the raw timestamp value we should use, and skip strtotime
755 must set to null since there is no "0" date (i.e. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC)
759 strongly type the data
761 dont quote numbers
767 trim leading $ before the hard cast to int (PHP will cast something like "$3.50" to 0 otherwise)
768 regular whitespace trim PLUS dollar sign. ref: http://php.net/manual/en/function.trim.php
777 trim leading $ before the hard cast to float (PHP will cast something like "$3.50" to 0 otherwise)
778 regular whitespace trim PLUS dollar sign. ref: http://php.net/manual/en/function.trim.php
784 needs quotes. this data type stores binary strings that have no character set or collation (it is NOT strictly ones and zeros)
785 force binary to be 0 if nothing is set
802 false should evalute to empty string
810 ///////////////////////////// Serialize/Unserialize Array/Object functions ///////////////////////////////////
853 force null if nothing is set. note, this includes an empty array
854 verify array type
855 not an array, though it may already be serialized. test it
856 returns false if not serialized
857 not valid array or serizlied array
858 make the given $array valid. return the passed value as the only item in the serialized array
871 force null if nothing is set
872 verify object type
873 not an object, though it may already be serialized. test it
874 returns false if not serialized
875 not valid object or serizlied object
889 return empty array always instead of null
891 could not unserialize
892 return value as is, inside an array
908 ////////////////////////// FORM STUFF //////////////////////////////////
926 ///////////////////////////// Invoke ///////////////////////////////////
939 ///////////////////////////// ERROR ON INVALID FUNCTIONS/VARS //////////////////////////
961 end class
TODO 546 Implement table's with composite keys into this function
TODO 572 Implement table's with composite keys into this function
TODO 156 implement this
TODO 161 implement this. and maybe default to true instead of false
TODO 221 Implement the SortOrder property for columns. 1-indexed to distinguish 0 from null/not set?

SmartCell.php 224

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
21 ///////////////////////////// SERIALIZATION - At top so we don't forget to update these when we add new vars //////////////////////////
38 //////////////////////////////////////////////////////////////////////////////////////////////////////
90 ///////////////////////////// COLUMN WRAPPERS ///////////////////////////////
112 /////////////////////////////////////////////////////////////////////////////
120 this shorthand is recommended:
121 same thing as $row['YOUR_COLUMN_NAME']->GetValue();
122 same thing as $row['YOUR_COLUMN_NAME']->GetValue(true);
124 NOTE: This is not recommended, but you can skip the function call (i.e. $row['YOUR_COLUMN_NAME']) when the returned value is used as a STRING ONLY! Otherwise, $row['YOUR_COLUMN_NAME'] gives you the actual SmartCell object. For example:
125 is fine and will echo the column value
126 is fine and will compare the column value to "my data"
127 is NOT fine since we're not doing string comparison. this statement will try to compare the actual SmartCell object with the int 3 and will lead to bad things.
128 is fine
129 is fine and RECOMMENDED (just always invoke the Column/Cell directly like this)
130 is fine
139 initialize the row if not a primary key. may set $this->_value
143 depending on the column's data type, we may need to normalize the raw database value for everyday use
146 handle special return options (as described in the function comments)
147 note- serialized columns (arrays, objects) do not have special return options, so ignore that parameter for those types.
149 is a date column
150 match. special check for "0000-00-00 00:00:00". different OS's and PHP versions handle strtotim("0000-00-00 00:00:00") differently
156 if false, strtotime failed and couldn't parse a date
159 not a date column
175 initialize the row if not a primary key. may set $this->_value
195 changing a primary key column value?
197 setting a non-autoincrement, non composite key
203 changing a non primary key column value
207 event cancelled, do not set the value
217 notify the row that a cell's value had changed
248 do this instead of unset. unset loses our private $_value and forces the value to be set on the Column level next time through, thanks to magic functions
251 TODO: may need these Compress() and Uncompress() functions at that point?
258 private function Compress($txt){
259 return base64_encode(gzcompress($txt));
260 }
267 private function Uncompress($txt){
268 return gzuncompress(base64_decode($txt));
269 }
277 check null first. only allow null special if this column is NOT required (ie NULL sf a valid value)
288 special case with \0 not recognized as null/false
291 special case with \0 not recognized as null/false
307 $compareValue will be serialized at this point, as is _value
308 $compareValue will be serialized at this point, as is _value
323 Either a string of the column to sort ASC by, or an assoc array of "ColumnName"=>"ASC"|"DESC" to sort by. An exception will be thrown if a column does not exist.
324 if true, the returned assoc-array will have the row's primary key column value as its key and the row as its value. ie array("2"=>$row,...) instead of just array($row,...);
325 OUT variable. integer. if you set this parameter in the $options array, then this function will return only 1 row of the result set at a time. If there are no rows selected or left to iterate over, null is returned.
326 THIS PARAMETER MUST BE PASSED BY REFERENCE - i.e. array( "return-next-row" => &$curCount ) - the incoming value of this parameter doesn't matter and will be overwritten)
327 After this function is executed, this OUT variable will be set with the number of rows that have been returned thus far.
328 Each consecutive call to this function with the 'return-next-row' option set will return the next row in the result set, and also increment the 'return-next-row' variable to the number of rows that have been returned thus far
329 With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set
330 With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
331 OUT variable only. integer. after this function is executed, this variable will be set with the number of rows being returned. Usage ex: array('return-count'=>&$count)
332 if true, the return-count will be returned instead of the rows. A good optimization if you dont need to read any data from the rows and just need the rowcount of the search.
341 shortcut support for GetRelatedRows(tableName, options)
345 shortcut support for GetRelatedRows(tableName)
381 ///////////////////////////// CALLBACK STUFF ///////////////////////////////////
382 event callback arrays
383 callbacks to be fired when this column has been set (not necessarily 'changed')
384 callbacks to be fired before this column has been changed
385 callbacks to be fired after this column has been changed
398 no callbacks defined or callbacks disabled
400 pass $this->Row reference back through to the callback
414 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
415 a reference to the Cell that fired the event
416 the current value of this column, BEFORE it has changed to 'new-value'
417 the value that this column is going to be set to, replacing the 'current-value'. Changing this value in your $callbackFunction will change the value that the column will be set to.
438 setting 'cancel-event' to true within your $callbackFunction will prevent the event from continuing
439 a reference to the Cell that fired the event
440 the current value of this column, BEFORE it has changed to 'new-value'
441 the value that this column is going to be set to, replacing the 'current-value'. Changing this value in your $callbackFunction will change the value that the column will be set to.
465 a reference to the Cell that fired the event
466 the current value of this column, AFTER it has been changed from 'old-value'
467 the value that this column was set to before it was updated with the 'current-value'
482 ///////////////////////////// FORM STUFF ///////////////////////////////////
527 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
528 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
538 OPTIONS
539 default options
542 overwrite $defaultOptions with any $options specified
547 get $currentValue (note: BuildAttribsHtml() does htmlspecialchars)
550 ATTRIBS
564 overwrite $defaultAttribs with any $customAttribs specified
570 formatter callback
582 should be something unique, doesnt matter what
588 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
589 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
599 OPTIONS
600 default options
603 overwrite $defaultOptions with any $options specified
609 get formatted value
615 ATTRIBS
629 overwrite $defaultAttribs with any $customAttribs specified
635 formatter callback
650 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
651 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
662 OPTIONS
663 default options
666 overwrite $defaultOptions with any $options specified
672 get formatted $value
673 don't get the raw value
676 not checked. but need a value for the checkbox in case user checks it
679 current value is set
684 ATTRIBS
695 overwrite $defaultAttribs with any $customAttribs specified
701 formatter callback
710 HIDDEN NOTIFIER ATTRIBS
720 overwrite $defaultAttribs with any $customAttribs specified
738 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
739 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
740 if true, an empty option will be the first option printed
741 string. if set, the given key within $keyValuePairs will be forced as the selected option (if found. if not found, the browser's default choice will be selected, probably the first in the list)
742 if true, this will populate the select object with the "PossibleValues" for this particular column (as defined in the xml db schema)
755 OPTIONS
756 default options
760 overwrite $defaultOptions with any $options specified
765 set the 'use-possible-values' option to true if this parameter is true. it's a shortcut
769 ATTRIBS
776 overwrite $defaultAttribs with any $customAttribs specified
782 SELECT TAG
786 OPTIONS
794 get formatted $currentValue
798 populate select values from xml
821 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
822 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
823 the actual shown value of the text area (if not using the default value from this cell)
833 get $currentValue (BuildAttribsHtml() does htmlspecialchars)
836 get formatted $currentValue
839 OPTIONS
840 default options
844 overwrite $defaultOptions with any $options specified
850 ATTRIBS
860 overwrite $defaultAttribs with any $customAttribs specified
880 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
890 OPTIONS
892 default options
894 overwrite $defaultOptions with any $options specified
900 get $currentValue (BuildAttribsHtml() does htmlspecialchars)
903 ATTRIBS
912 overwrite $defaultAttribs with any $customAttribs specified
918 formatter callback
934 if true, this radio button will be checked regardless of the current Cell value. if false, this radio button will be checked only if the value matches the one currently in the Cell
935 if true, this radio button will be checked only if the current Cell value for thi column is null. defaults to true if the current value is 0 or empty string
936 a string for the text of the label next to the radio button. if this field is left empty, no label will be included with the button
937 can be "left" or "right", relative to the radio button (only if ['include-label']=true)
938 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
950 OPTIONS
951 default options
953 defaults to true if the current value is 0 or empty string
954 deprecated. alias to checked-if-null
958 overwrite $defaultOptions with any $options specified
960 support legacy options
967 "checked-if-null" radio option should default to true if the current value is 0 or empty string
968 if(!$formValue && ($currentValue === 0 || $currentValue === '')){
969 $options['checked-if-null'] = true;
970 }
977 ATTRIBS
987 overwrite $defaultAttribs with any $customAttribs specified
993 formatter callback
1010 strips any characters not valid for an HTML ID
1028 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
1029 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
1039 OPTIONS
1040 default options
1043 overwrite $defaultOptions with any $options specified
1048 get $currentValue (BuildAttribsHtml() does htmlspecialchars)
1051 ATTRIBS
1065 overwrite $defaultAttribs with any $customAttribs specified
1071 formatter callback
1085 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
1086 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
1096 OPTIONS
1097 default options
1100 overwrite $defaultOptions with any $options specified
1105 get formatted $currentValue
1108 ATTRIBS
1122 overwrite $defaultAttribs with any $customAttribs specified
1128 formatter callback
1142 if true, a '*' will be appended to the end of the input field (note: default value may be set on the Column. use this field to overwrite the default value)
1143 can be either: 1. array("functionName", $obj) if function belongs to $obj, 2. array("functionName", "className") if the function is static within class "classname", or 3. just "functionName" if function is in global scope. this function will be called when getting the form object and the value returned by it will be used as the form object's value. the callback's signiture is functionName($value), where $value is the current cell value
1153 OPTIONS
1154 default options
1157 overwrite $defaultOptions with any $options specified
1162 get formatted $currentValue
1165 ATTRIBS
1176 overwrite $defaultAttribs with any $customAttribs specified
1182 formatter callback
1214 the id of the form object that this label is for. this should be left as default on most cases as the default name will be generated so it can be tracked by this class; custom names require you to handle organization of matching label names to form object ids
1215 the text or html of the label. empty will use the column's DisplayName (if set), otherwise uses the ColumnName
1216 adds a text or html prefix to the label
1217 adds a text or html suffix to the label
1218 if true, will html-special-chars the prefix, label-text, and suffix
1225 reverse compatible
1226 default options
1233 overwrite $defaultOptions with any $options specified
1238 if true, will html-special-chars the prefix, label-text, and suffix
1248 ///////////////////////////// INPUT VALIDATION ///////////////////////////////////
1257 If true: does not validate the key columns. If false: validates all columns
1258 If true: only cells that have been set (i.e. isset()==true) will be verified (not recommended if this info will be committed to db). If false: all cells will be verified (should be used if this info will be committed to db).
1259 appended to each error message
1266 default options
1269 overwrite $defaultOptions with any $options specified
1281 need to validate that the value is valid (mostly for enumerations)
1282 for mysql, enum has null and "" as separate valid values and "" is ALWAYS valid... wtf? make it so "" and null are equal and always valid. will be caught later if null is not allowed
1286 non-null value
1287 for mysql, enums are case-insensetitive! "AAA"=="aAa" as valid enum values
1288 case-insensitive array search
1297 int 0 is different from "0" (http://php.net/manual/en/types.comparisons.php). int 0 will consider the column as set for all datatypes except binary
1298 so.. if the column is binary and the value is int 0, this is an error. if the column is anything else besides binary, this is NOT an error
1317 ignore this if the field is required and empty. already have that error message
1320 let this case pass because input is not required
1330 ignore regex if the field is required and empty. already have that error message
1332 let this case pass because input is not required
1334 both PHP and javascript do case-insensitive regex checking
1344 ignore 'null' values when checking uniqueness
1349 $this row doesnt exist, so the found value is in use in another row
1351 get formatted $currentValue
1357 $this row does exist. see if the found value is part of $this row by comparing key column(s)
1362 found row is not $this row, so found value is in use in another row
1364 get formatted $currentValue
1373 no other way to automatically determine if the found value is part of this row. leave it to the programmer/mysql errors for duplicates
1383 ///////////////////////////// ArrayAccess ///////////////////////////////////
1430 ///////////////////////////// Countable ///////////////////////////////////
1441 ////////////////////////// IteratorAggregate /////////////////////////////
1452 end class

FormValidation/SmartFormValidation_jQueryValidate.php 18

Type Line Description
4 www.phpsmartdb.com/
8 www.phpsmartdb.com/license
23 validate page properties form
81 $Column doesnt matter if $Table isnt set, so no need to check it
82 return rules for the entire Database
92 return rules for the given $Column
97 if(!empty($Table)){
98 return rules for the given $Table
115 Makes the element always required.
118 Makes the element require a given minimum length.
122 Makes the element require a given maxmimum length.
125 Makes the element require matching the regex
130 if($Column->){
131 $js .= "number: {$Column->MinSize},"; //Makes the element require a decimal number.
132 }
136 if($Column->){
137 $js .= "digits: {$Column->Digits},"; //Makes the element require digits only.
138 }