├── CHANGELOG ├── README.md ├── config.php ├── dumbledorm.php ├── generate.php └── test.php /CHANGELOG: -------------------------------------------------------------------------------- 1 | 0.1 - Dec 18 2010 2 | -added MIT License 3 | -updated and reformatted documentation (thanks to nvartolomei for the first pass) 4 | -fixed bug where certain data may be hydrated incorrectly in Db::hydrate 5 | -added PDO::ERRMODE_EXCEPTION to connection attributes (fixes bug reported by https://github.com/jiminoc) 6 | -added execute method to Db class 7 | -refactored save/delete methods to use new execute() method 8 | -updated test.php to use new execute() method 9 | 10 | 0.1.1 - Dec 31 2010 11 | -Big bugfix on updates that caused updating multiple fields in a single save() to fail 12 | -Fixed bug where ordering in update data fields may be mismatched 13 | -Added new PlainSql class for inserting plain sql such as NOW() or DATE(NOW()) into sql values 14 | -Setting null to a field in php will set the field to NULL in mysql update/insert statement (before only set to empty string) 15 | -Updated the docs with some undocumented functionality 16 | -Updated test.php with more tests for new/previously undocumented functionality -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #DumbledORM 2 | A PHP Novelty ORM 3 | 4 | ##Requirements: 5 | * PHP 5.3+ 6 | * All tables must have a single (not composite) primary key called `id` that is an auto-incrementing integer 7 | * All foreign keys must follow the convention of `table_name_id` 8 | * All meta tables must be: 9 | * named `table_name_meta` 10 | * have a foreign key to the corresponding parent table 11 | * have a column called `key` 12 | * have a column called `val` 13 | 14 | 15 | ##Setup: 16 | 17 | 1. Download/clone DumbledORM 18 | 2. Ensure that your config.php has the correct host, user, pass, etc. 19 | 3. When you have set up your database or have made a change, go to the command line and type ```./generate.php``` 20 | 4. Add the following lines to your code: 21 | 22 | require('config.php'); 23 | require('dumbledorm.php'); 24 | require('./model/base.php'); 25 | 26 | That's it. There's an autoloader built in for the generated classes. 27 | 28 | ###Database configuration 29 | 30 | The PHP Data objects or PDO extension is used to access mysql and the configuration file `config.php` is home for class 31 | DbConfig the source where DumbledORM finds your database settings. 32 | 33 | You are able to configure the settings for host, port, database, username and password. 34 | 35 | ``` 36 | class DbConfig { 37 | const HOST = 'localhost'; 38 | const PORT = 3306; 39 | const DBNAME = 'test_database'; 40 | const USER = 'root'; 41 | const PASSWORD = 'password'; 42 | } 43 | ``` 44 | 45 | NOTE: On rare occations mysql will not resolve localhost and PDO will attempt to connect to a unix socket, 46 | if this fails you will likely find a PDOException complaining that there is "No such file or directory". 47 | By changing localhost to the ip 127.0.0.1 instead mysql will be able to resolve the host and a connection can be established. 48 | 49 | ###CLI Script generate.php 50 | 51 | DumbledORM includes a PHP script to generate your database schema model classes. 52 | 53 | At the command line type ```./generate.php -h``` for usage 54 | 55 | ``` 56 | Generate DumbledORM models. 57 | 58 | Usage: 59 | ./generate.php