my-simon 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/.document +5 -0
  2. data/.gitignore.orig +55 -0
  3. data/DOC/Launch Check List.docx +0 -0
  4. data/DOC/Launch Check List.pdf +0 -0
  5. data/Gemfile +14 -0
  6. data/Gemfile.lock +44 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +21 -0
  9. data/README.rdoc +19 -0
  10. data/Rakefile +46 -0
  11. data/VERSION +1 -0
  12. data/build/rakefile.rb +12 -0
  13. data/config.rb +24 -0
  14. data/lib/simon.rb +0 -5
  15. data/my-simon.gemspec +141 -0
  16. data/scaffolding/simon/controller.tpl +9 -0
  17. data/scaffolding/simon/model.tpl +10 -0
  18. data/scaffolding/simon/view.tpl +5 -0
  19. data/scaffolding/standards/html_template.html +44 -0
  20. data/scaffolding/standards/html_template.php +44 -0
  21. data/scaffolding/standards/jquery_plugin_template.js +45 -0
  22. data/scaffolding/standards/js_template.js +43 -0
  23. data/simon +282 -0
  24. data/test/helper.rb +18 -0
  25. data/test/test_simon.rb +7 -0
  26. data/www/.htaccess +488 -0
  27. data/www/404.html +32 -0
  28. data/www/crossdomain.xml +25 -0
  29. data/www/favicon.ico +0 -0
  30. data/www/index.php +17 -0
  31. data/www/lib/js/homePage.js +43 -0
  32. data/www/lib/js/jquery/JQbook.js +809 -0
  33. data/www/lib/js/jquery/jquery-1.8.0.min.js +27 -0
  34. data/www/lib/js/jquery/jquery.alphanumeric.js +82 -0
  35. data/www/lib/js/jquery/jquery.cookie.js +96 -0
  36. data/www/lib/js/jquery/jquery.easing.1.3.js +207 -0
  37. data/www/lib/js/main.js +117 -0
  38. data/www/lib/js/master.js +6 -0
  39. data/www/lib/js/plugins/handlebars-1.0.rc.1.js +1920 -0
  40. data/www/lib/js/plugins/modernizr-1.7.min.js +2 -0
  41. data/www/lib/js/plugins/swfobject.js +777 -0
  42. data/www/lib/js/plugins_mod/README.txt +3 -0
  43. data/www/lib/php/app.php +53 -0
  44. data/www/lib/php/controller/index.php +10 -0
  45. data/www/lib/php/controller/regex.php +23 -0
  46. data/www/lib/php/model/Book.php +8 -0
  47. data/www/lib/php/model/Model.php +8 -0
  48. data/www/lib/php/plugins/php-activerecord/ActiveRecord.php +44 -0
  49. data/www/lib/php/plugins/php-activerecord/lib/CallBack.php +226 -0
  50. data/www/lib/php/plugins/php-activerecord/lib/Column.php +155 -0
  51. data/www/lib/php/plugins/php-activerecord/lib/Config.php +288 -0
  52. data/www/lib/php/plugins/php-activerecord/lib/Connection.php +456 -0
  53. data/www/lib/php/plugins/php-activerecord/lib/ConnectionManager.php +38 -0
  54. data/www/lib/php/plugins/php-activerecord/lib/DateTime.php +45 -0
  55. data/www/lib/php/plugins/php-activerecord/lib/Exceptions.php +137 -0
  56. data/www/lib/php/plugins/php-activerecord/lib/Expressions.php +183 -0
  57. data/www/lib/php/plugins/php-activerecord/lib/Inflector.php +115 -0
  58. data/www/lib/php/plugins/php-activerecord/lib/Model.php +1673 -0
  59. data/www/lib/php/plugins/php-activerecord/lib/Reflections.php +86 -0
  60. data/www/lib/php/plugins/php-activerecord/lib/Relationship.php +637 -0
  61. data/www/lib/php/plugins/php-activerecord/lib/SQLBuilder.php +396 -0
  62. data/www/lib/php/plugins/php-activerecord/lib/Serialization.php +302 -0
  63. data/www/lib/php/plugins/php-activerecord/lib/Singleton.php +57 -0
  64. data/www/lib/php/plugins/php-activerecord/lib/Table.php +547 -0
  65. data/www/lib/php/plugins/php-activerecord/lib/Utils.php +351 -0
  66. data/www/lib/php/plugins/php-activerecord/lib/Validations.php +833 -0
  67. data/www/lib/php/plugins/php-activerecord/lib/adapters/MysqlAdapter.php +73 -0
  68. data/www/lib/php/plugins/php-activerecord/lib/adapters/OciAdapter.php +121 -0
  69. data/www/lib/php/plugins/php-activerecord/lib/adapters/PgsqlAdapter.php +104 -0
  70. data/www/lib/php/plugins/php-activerecord/lib/adapters/SqliteAdapter.php +81 -0
  71. data/www/lib/php/system/Config.php +174 -0
  72. data/www/lib/php/system/config.routes.php +29 -0
  73. data/www/lib/php/system/router.php +220 -0
  74. data/www/lib/php/template/footer.php +59 -0
  75. data/www/lib/php/template/header.php +74 -0
  76. data/www/lib/php/view/index.php +5 -0
  77. data/www/media/images/facebook_share.jpg +0 -0
  78. data/www/robots.txt +5 -0
  79. data/www/sandbox/readme.txt +3 -0
  80. data/www/sass/javascript.scss +1 -0
  81. data/www/sass/layout.scss +128 -0
  82. data/www/sass/master.scss +4 -0
  83. data/www/sass/reset.scss +47 -0
  84. data/www/sass/typography.scss +24 -0
  85. data/www/styles/javascript.css +1 -0
  86. data/www/styles/layout.css +186 -0
  87. data/www/styles/master.css +4 -0
  88. data/www/styles/reset.css +60 -0
  89. data/www/styles/typography.css +24 -0
  90. metadata +179 -7
@@ -0,0 +1,456 @@
1
+ <?php
2
+ /**
3
+ * @package ActiveRecord
4
+ */
5
+ namespace ActiveRecord;
6
+
7
+ require 'Column.php';
8
+
9
+ use PDO;
10
+ use PDOException;
11
+ use Closure;
12
+
13
+ /**
14
+ * The base class for database connection adapters.
15
+ *
16
+ * @package ActiveRecord
17
+ */
18
+ abstract class Connection
19
+ {
20
+ /**
21
+ * The PDO connection object.
22
+ * @var mixed
23
+ */
24
+ public $connection;
25
+
26
+ /**
27
+ * The last query run.
28
+ * @var string
29
+ */
30
+ public $last_query;
31
+
32
+ /**
33
+ * Switch for logging.
34
+ *
35
+ * @var bool
36
+ */
37
+ private $logging = false;
38
+
39
+ /**
40
+ * Contains a Logger object that must impelement a log() method.
41
+ *
42
+ * @var object
43
+ */
44
+ private $logger;
45
+
46
+ /**
47
+ * Default PDO options to set for each connection.
48
+ * @var array
49
+ */
50
+ static $PDO_OPTIONS = array(
51
+ PDO::ATTR_CASE => PDO::CASE_LOWER,
52
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
53
+ PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
54
+ PDO::ATTR_STRINGIFY_FETCHES => false);
55
+
56
+ /**
57
+ * The quote character for stuff like column and field names.
58
+ * @var string
59
+ */
60
+ static $QUOTE_CHARACTER = '`';
61
+
62
+ /**
63
+ * Default port.
64
+ * @var int
65
+ */
66
+ static $DEFAULT_PORT = 0;
67
+
68
+ /**
69
+ * Retrieve a database connection.
70
+ *
71
+ * @param string $connection_string_or_connection_name A database connection string (ex. mysql://user:pass@host[:port]/dbname)
72
+ * Everything after the protocol:// part is specific to the connection adapter.
73
+ * OR
74
+ * A connection name that is set in ActiveRecord\Config
75
+ * If null it will use the default connection specified by ActiveRecord\Config->set_default_connection
76
+ * @return Connection
77
+ * @see parse_connection_url
78
+ */
79
+ public static function instance($connection_string_or_connection_name=null)
80
+ {
81
+ $config = Config::instance();
82
+
83
+ if (strpos($connection_string_or_connection_name,'://') === false)
84
+ {
85
+ $connection_string = $connection_string_or_connection_name ?
86
+ $config->get_connection($connection_string_or_connection_name) :
87
+ $config->get_default_connection_string();
88
+ }
89
+ else
90
+ $connection_string = $connection_string_or_connection_name;
91
+
92
+ if (!$connection_string)
93
+ throw new DatabaseException("Empty connection string");
94
+
95
+ $info = static::parse_connection_url($connection_string);
96
+ $fqclass = static::load_adapter_class($info->protocol);
97
+
98
+ try {
99
+ $connection = new $fqclass($info);
100
+ $connection->protocol = $info->protocol;
101
+ $connection->logging = $config->get_logging();
102
+ $connection->logger = $connection->logging ? $config->get_logger() : null;
103
+ } catch (PDOException $e) {
104
+ throw new DatabaseException($e);
105
+ }
106
+ return $connection;
107
+ }
108
+
109
+ /**
110
+ * Loads the specified class for an adapter.
111
+ *
112
+ * @param string $adapter Name of the adapter.
113
+ * @return string The full name of the class including namespace.
114
+ */
115
+ private static function load_adapter_class($adapter)
116
+ {
117
+ $class = ucwords($adapter) . 'Adapter';
118
+ $fqclass = 'ActiveRecord\\' . $class;
119
+ $source = dirname(__FILE__) . "/adapters/$class.php";
120
+
121
+ if (!file_exists($source))
122
+ throw new DatabaseException("$fqclass not found!");
123
+
124
+ require_once($source);
125
+ return $fqclass;
126
+ }
127
+
128
+ /**
129
+ * Use this for any adapters that can take connection info in the form below
130
+ * to set the adapters connection info.
131
+ *
132
+ * <code>
133
+ * protocol://username:password@host[:port]/dbname
134
+ * protocol://urlencoded%20username:urlencoded%20password@host[:port]/dbname?decode=true
135
+ * protocol://username:password@unix(/some/file/path)/dbname
136
+ * </code>
137
+ *
138
+ * @param string $connection_url A connection URL
139
+ * @return object the parsed URL as an object.
140
+ */
141
+ public static function parse_connection_url($connection_url)
142
+ {
143
+ $url = @parse_url($connection_url);
144
+
145
+ if (!isset($url['host']))
146
+ throw new DatabaseException('Database host must be specified in the connection string.');
147
+
148
+ $info = new \stdClass();
149
+ $info->protocol = $url['scheme'];
150
+ $info->host = $url['host'];
151
+ $info->db = isset($url['path']) ? substr($url['path'],1) : null;
152
+ $info->user = isset($url['user']) ? $url['user'] : null;
153
+ $info->pass = isset($url['pass']) ? $url['pass'] : null;
154
+
155
+ if ($info->host == 'unix(')
156
+ {
157
+ $socket_database = $info->host . '/' . $info->db;
158
+
159
+ if (preg_match_all('/^unix\((.+)\)\/(.+)$/', $socket_database, $matches) > 0)
160
+ {
161
+ $info->host = $matches[1][0];
162
+ $info->db = $matches[2][0];
163
+ }
164
+ }
165
+
166
+ if (isset($url['port']))
167
+ $info->port = $url['port'];
168
+
169
+ if (strpos($connection_url,'decode=true') !== false)
170
+ {
171
+ if ($info->user)
172
+ $info->user = urldecode($info->user);
173
+
174
+ if ($info->pass)
175
+ $info->pass = urldecode($info->pass);
176
+ }
177
+
178
+ return $info;
179
+ }
180
+
181
+ /**
182
+ * Class Connection is a singleton. Access it via instance().
183
+ *
184
+ * @param array $info Array containing URL parts
185
+ * @return Connection
186
+ */
187
+ protected function __construct($info)
188
+ {
189
+ try
190
+ {
191
+ // unix sockets start with a /
192
+ if ($info->host[0] != '/')
193
+ {
194
+ $host = "host=$info->host";
195
+
196
+ if (isset($info->port))
197
+ $host .= ";port=$info->port";
198
+ }
199
+ else
200
+ $host = "unix_socket=$info->host";
201
+
202
+ $this->connection = new PDO("$info->protocol:$host;dbname=$info->db",$info->user,$info->pass,static::$PDO_OPTIONS);
203
+ } catch (PDOException $e) {
204
+ throw new DatabaseException($e);
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Retrieves column meta data for the specified table.
210
+ *
211
+ * @param string $table Name of a table
212
+ * @return array An array of {@link Column} objects.
213
+ */
214
+ public function columns($table)
215
+ {
216
+ $columns = array();
217
+ $sth = $this->query_column_info($table);
218
+
219
+ while (($row = $sth->fetch()))
220
+ {
221
+ $c = $this->create_column($row);
222
+ $columns[$c->name] = $c;
223
+ }
224
+ return $columns;
225
+ }
226
+
227
+ /**
228
+ * Escapes quotes in a string.
229
+ *
230
+ * @param string $string The string to be quoted.
231
+ * @return string The string with any quotes in it properly escaped.
232
+ */
233
+ public function escape($string)
234
+ {
235
+ return $this->connection->quote($string);
236
+ }
237
+
238
+ /**
239
+ * Retrieve the insert id of the last model saved.
240
+ *
241
+ * @param string $sequence Optional name of a sequence to use
242
+ * @return int
243
+ */
244
+ public function insert_id($sequence=null)
245
+ {
246
+ return $this->connection->lastInsertId($sequence);
247
+ }
248
+
249
+ /**
250
+ * Execute a raw SQL query on the database.
251
+ *
252
+ * @param string $sql Raw SQL string to execute.
253
+ * @param array &$values Optional array of bind values
254
+ * @return mixed A result set object
255
+ */
256
+ public function query($sql, &$values=array())
257
+ {
258
+ if ($this->logging)
259
+ $this->logger->log($sql);
260
+
261
+ $this->last_query = $sql;
262
+
263
+ try {
264
+ if (!($sth = $this->connection->prepare($sql)))
265
+ throw new DatabaseException($this);
266
+ } catch (PDOException $e) {
267
+ throw new DatabaseException($this);
268
+ }
269
+
270
+ $sth->setFetchMode(PDO::FETCH_ASSOC);
271
+
272
+ try {
273
+ if (!$sth->execute($values))
274
+ throw new DatabaseException($this);
275
+ } catch (PDOException $e) {
276
+ throw new DatabaseException($sth);
277
+ }
278
+ return $sth;
279
+ }
280
+
281
+ /**
282
+ * Execute a query that returns maximum of one row with one field and return it.
283
+ *
284
+ * @param string $sql Raw SQL string to execute.
285
+ * @param array &$values Optional array of values to bind to the query.
286
+ * @return string
287
+ */
288
+ public function query_and_fetch_one($sql, &$values=array())
289
+ {
290
+ $sth = $this->query($sql,$values);
291
+ $row = $sth->fetch(PDO::FETCH_NUM);
292
+ return $row[0];
293
+ }
294
+
295
+ /**
296
+ * Execute a raw SQL query and fetch the results.
297
+ *
298
+ * @param string $sql Raw SQL string to execute.
299
+ * @param Closure $handler Closure that will be passed the fetched results.
300
+ */
301
+ public function query_and_fetch($sql, Closure $handler)
302
+ {
303
+ $sth = $this->query($sql);
304
+
305
+ while (($row = $sth->fetch(PDO::FETCH_ASSOC)))
306
+ $handler($row);
307
+ }
308
+
309
+ /**
310
+ * Returns all tables for the current database.
311
+ *
312
+ * @return array Array containing table names.
313
+ */
314
+ public function tables()
315
+ {
316
+ $tables = array();
317
+ $sth = $this->query_for_tables();
318
+
319
+ while (($row = $sth->fetch(PDO::FETCH_NUM)))
320
+ $tables[] = $row[0];
321
+
322
+ return $tables;
323
+ }
324
+
325
+ /**
326
+ * Starts a transaction.
327
+ */
328
+ public function transaction()
329
+ {
330
+ if (!$this->connection->beginTransaction())
331
+ throw new DatabaseException($this);
332
+ }
333
+
334
+ /**
335
+ * Commits the current transaction.
336
+ */
337
+ public function commit()
338
+ {
339
+ if (!$this->connection->commit())
340
+ throw new DatabaseException($this);
341
+ }
342
+
343
+ /**
344
+ * Rollback a transaction.
345
+ */
346
+ public function rollback()
347
+ {
348
+ if (!$this->connection->rollback())
349
+ throw new DatabaseException($this);
350
+ }
351
+
352
+ /**
353
+ * Tells you if this adapter supports sequences or not.
354
+ *
355
+ * @return boolean
356
+ */
357
+ function supports_sequences() { return false; }
358
+
359
+ /**
360
+ * Return a default sequence name for the specified table.
361
+ *
362
+ * @param string $table Name of a table
363
+ * @param string $column_name Name of column sequence is for
364
+ * @return string sequence name or null if not supported.
365
+ */
366
+ public function get_sequence_name($table, $column_name)
367
+ {
368
+ return "{$table}_seq";
369
+ }
370
+
371
+ /**
372
+ * Return SQL for getting the next value in a sequence.
373
+ *
374
+ * @param string $sequence_name Name of the sequence
375
+ * @return string
376
+ */
377
+ public function next_sequence_value($sequence_name) { return null; }
378
+
379
+ /**
380
+ * Quote a name like table names and field names.
381
+ *
382
+ * @param string $string String to quote.
383
+ * @return string
384
+ */
385
+ public function quote_name($string)
386
+ {
387
+ return $string[0] === static::$QUOTE_CHARACTER || $string[strlen($string)-1] === static::$QUOTE_CHARACTER ?
388
+ $string : static::$QUOTE_CHARACTER . $string . static::$QUOTE_CHARACTER;
389
+ }
390
+
391
+ /**
392
+ * Return a date time formatted into the database's date format.
393
+ *
394
+ * @param DateTime $datetime The DateTime object
395
+ * @return string
396
+ */
397
+ public function date_to_string($datetime)
398
+ {
399
+ return $datetime->format('Y-m-d');
400
+ }
401
+
402
+ /**
403
+ * Return a date time formatted into the database's datetime format.
404
+ *
405
+ * @param DateTime $datetime The DateTime object
406
+ * @return string
407
+ */
408
+ public function datetime_to_string($datetime)
409
+ {
410
+ return $datetime->format('Y-m-d H:i:s T');
411
+ }
412
+
413
+ /**
414
+ * Converts a string representation of a datetime into a DateTime object.
415
+ *
416
+ * @param string $string A datetime in the form accepted by date_create()
417
+ * @return DateTime
418
+ */
419
+ public function string_to_datetime($string)
420
+ {
421
+ $date = date_create($string);
422
+ $errors = \DateTime::getLastErrors();
423
+
424
+ if ($errors['warning_count'] > 0 || $errors['error_count'] > 0)
425
+ return null;
426
+
427
+ return new DateTime($date->format('Y-m-d H:i:s T'));
428
+ }
429
+
430
+ /**
431
+ * Adds a limit clause to the SQL query.
432
+ *
433
+ * @param string $sql The SQL statement.
434
+ * @param int $offset Row offset to start at.
435
+ * @param int $limit Maximum number of rows to return.
436
+ * @return string The SQL query that will limit results to specified parameters
437
+ */
438
+ abstract function limit($sql, $offset, $limit);
439
+
440
+ /**
441
+ * Query for column meta info and return statement handle.
442
+ *
443
+ * @param string $table Name of a table
444
+ * @return PDOStatement
445
+ */
446
+ abstract public function query_column_info($table);
447
+
448
+ /**
449
+ * Query for all tables in the current database. The result must only
450
+ * contain one column which has the name of the table.
451
+ *
452
+ * @return PDOStatement
453
+ */
454
+ abstract function query_for_tables();
455
+ };
456
+ ?>
@@ -0,0 +1,38 @@
1
+ <?php
2
+ /**
3
+ * @package ActiveRecord
4
+ */
5
+ namespace ActiveRecord;
6
+
7
+ /**
8
+ * Singleton to manage any and all database connections.
9
+ *
10
+ * @package ActiveRecord
11
+ */
12
+ class ConnectionManager extends Singleton
13
+ {
14
+ /**
15
+ * Array of {@link Connection} objects.
16
+ * @var array
17
+ */
18
+ static private $connections = array();
19
+
20
+ /**
21
+ * If $name is null then the default connection will be returned.
22
+ *
23
+ * @see Config
24
+ * @param string $name Optional name of a connection
25
+ * @return Connection
26
+ */
27
+ public static function get_connection($name=null)
28
+ {
29
+ if (!isset(self::$connections[$name]) || !self::$connections[$name]->connection)
30
+ {
31
+ $config = Config::instance();
32
+ $connection_string = $name ? $config->get_connection($name) : $config->get_default_connection();
33
+ self::$connections[$name] = Connection::instance($connection_string);
34
+ }
35
+ return self::$connections[$name];
36
+ }
37
+ };
38
+ ?>
@@ -0,0 +1,45 @@
1
+ <?php
2
+ namespace ActiveRecord;
3
+
4
+ class DateTime extends \DateTime
5
+ {
6
+ private $model;
7
+ private $attribute_name;
8
+
9
+ public function attribute_of($model, $attribute_name)
10
+ {
11
+ $this->model = $model;
12
+ $this->attribute_name = $attribute_name;
13
+ }
14
+
15
+ private function flag_dirty()
16
+ {
17
+ if ($this->model)
18
+ $this->model->flag_dirty($this->attribute_name);
19
+ }
20
+
21
+ public function setDate($year, $month, $day)
22
+ {
23
+ $this->flag_dirty();
24
+ call_user_func_array(array($this,'parent::setDate'),func_get_args());
25
+ }
26
+
27
+ public function setISODate($year, $week , $day=null)
28
+ {
29
+ $this->flag_dirty();
30
+ call_user_func_array(array($this,'parent::setISODate'),func_get_args());
31
+ }
32
+
33
+ public function setTime($hour, $minute, $second=null)
34
+ {
35
+ $this->flag_dirty();
36
+ call_user_func_array(array($this,'parent::setTime'),func_get_args());
37
+ }
38
+
39
+ public function setTimestamp($unixtimestamp)
40
+ {
41
+ $this->flag_dirty();
42
+ call_user_func_array(array($this,'parent::setTimestamp'),func_get_args());
43
+ }
44
+ }
45
+ ?>
@@ -0,0 +1,137 @@
1
+ <?php
2
+ /**
3
+ * @package ActiveRecord
4
+ */
5
+ namespace ActiveRecord;
6
+
7
+ /**
8
+ * Generic base exception for all ActiveRecord specific errors.
9
+ *
10
+ * @package ActiveRecord
11
+ */
12
+ class ActiveRecordException extends \Exception {};
13
+
14
+ /**
15
+ * Thrown when a record cannot be found.
16
+ *
17
+ * @package ActiveRecord
18
+ */
19
+ class RecordNotFound extends ActiveRecordException {};
20
+
21
+ /**
22
+ * Thrown when there was an error performing a database operation.
23
+ *
24
+ * The error will be specific to whatever database you are running.
25
+ *
26
+ * @package ActiveRecord
27
+ */
28
+ class DatabaseException extends ActiveRecordException
29
+ {
30
+ public function __construct($adapter_or_string_or_mystery)
31
+ {
32
+ if ($adapter_or_string_or_mystery instanceof Connection)
33
+ {
34
+ parent::__construct(
35
+ join(", ",$adapter_or_string_or_mystery->connection->errorInfo()),
36
+ intval($adapter_or_string_or_mystery->connection->errorCode()));
37
+ }
38
+ elseif ($adapter_or_string_or_mystery instanceof \PDOStatement)
39
+ {
40
+ parent::__construct(
41
+ join(", ",$adapter_or_string_or_mystery->errorInfo()),
42
+ intval($adapter_or_string_or_mystery->errorCode()));
43
+ }
44
+ else
45
+ parent::__construct($adapter_or_string_or_mystery);
46
+ }
47
+ };
48
+
49
+ /**
50
+ * Thrown by {@link Model}.
51
+ *
52
+ * @package ActiveRecord
53
+ */
54
+ class ModelException extends ActiveRecordException {};
55
+
56
+ /**
57
+ * Thrown by {@link Expressions}.
58
+ *
59
+ * @package ActiveRecord
60
+ */
61
+ class ExpressionsException extends ActiveRecordException {};
62
+
63
+ /**
64
+ * Thrown for configuration problems.
65
+ *
66
+ * @package ActiveRecord
67
+ */
68
+ class ConfigException extends ActiveRecordException {};
69
+
70
+ /**
71
+ * Thrown when attempting to access an invalid property on a {@link Model}.
72
+ *
73
+ * @package ActiveRecord
74
+ */
75
+ class UndefinedPropertyException extends ModelException
76
+ {
77
+ /**
78
+ * Sets the exception message to show the undefined property's name.
79
+ *
80
+ * @param str $property_name name of undefined property
81
+ * @return void
82
+ */
83
+ public function __construct($class_name, $property_name)
84
+ {
85
+ if (is_array($property_name))
86
+ {
87
+ $this->message = implode("\r\n", $property_name);
88
+ return;
89
+ }
90
+
91
+ $this->message = "Undefined property: {$class_name}->{$property_name} in {$this->file} on line {$this->line}";
92
+ parent::__construct();
93
+ }
94
+ };
95
+
96
+ /**
97
+ * Thrown when attempting to perform a write operation on a {@link Model} that is in read-only mode.
98
+ *
99
+ * @package ActiveRecord
100
+ */
101
+ class ReadOnlyException extends ModelException
102
+ {
103
+ /**
104
+ * Sets the exception message to show the undefined property's name.
105
+ *
106
+ * @param str $class_name name of the model that is read only
107
+ * @param str $method_name name of method which attempted to modify the model
108
+ * @return void
109
+ */
110
+ public function __construct($class_name, $method_name)
111
+ {
112
+ $this->message = "{$class_name}::{$method_name}() cannot be invoked because this model is set to read only";
113
+ parent::__construct();
114
+ }
115
+ };
116
+
117
+ /**
118
+ * Thrown for validations exceptions.
119
+ *
120
+ * @package ActiveRecord
121
+ */
122
+ class ValidationsArgumentError extends ActiveRecordException {};
123
+
124
+ /**
125
+ * Thrown for relationship exceptions.
126
+ *
127
+ * @package ActiveRecord
128
+ */
129
+ class RelationshipException extends ActiveRecordException {};
130
+
131
+ /**
132
+ * Thrown for has many thru exceptions.
133
+ *
134
+ * @package ActiveRecord
135
+ */
136
+ class HasManyThroughAssociationException extends RelationshipException {};
137
+ ?>