|
Project Information
Members
Featured
Downloads
|
tableModel is a relatively small class (weighing in at only 317 lines and 9813 bytes without comments) that allows the developer to interact with MySQL tables as if they were... stdClasses: $myTable->columnName = 12; Arrays: $myTable[] = array('col1'=>'val1', 'col2'=>'val2'); jQuery objects: foreach ($myTable ->find('col1=%Q', $val1) ->filter('col2=%Q', $val2) as $index=>$item) var_dump($index, $item); And much more! tableModel makes good use of the new magic methods and interfaces found in PHP5's SPL. At present, it implements set, get, isset, ArrayAccess, Countable, and Iterator. Their use is generally intuitive, so you won't likely be checking out the documentation too often. Additionally, I made it a point to avoid using so much overloading that the basics aren't both available and extended: there are ->query (raw mysql_query), ->query (mysql query and return full result set), ->row (query, only return first row), ->column (query and return array of values), ->pick (query and get a single value), and ->execute i.e., $value = $instance->pick("SELECT value FROM aTable WHERE name like %Q LIMIT 1", $name); equivalent: $value = $instance ->find('name like %Q', $name) ->limit(1) ->value; Anyway, make sure to look at modeldocumentation.php - it should be able to get you started. I should note: the tableModel is not meant for bootstrapping tables; you should be doing that via your own means, whether it be to import SQL or to generate them programmatically. Work in Progress (2009-08-10): Updating to add support for TSV, CSV, SQLite, PgSQL, MSSQL, and database URIs (generally of the form [mysql|pgsql|mssql]://user:pass@host/table [csv|tsv]://filename[?col1&col2&col3 ... if omitted, headers are assumed] sqlite://filename#table |