v5:activerecord:active_record_tutorial
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
activerecord:active_record_tutorial [2015/12/08 05:09] – [LoadRelations] mnewnham | activerecord:active_record_tutorial [2015/12/08 05:37] – [ClassHasMany] mnewnham | ||
---|---|---|---|
Line 78: | Line 78: | ||
1048: Column ' | 1048: Column ' | ||
- | This error occurred because MySQL rejected the INSERT | + | This error occurred because MySQL rejected the INSERT |
To insert a new ADOdb_Active_Record in the database, populate all of ADOdb_Active_Record' | To insert a new ADOdb_Active_Record in the database, populate all of ADOdb_Active_Record' | ||
Line 337: | Line 337: | ||
===== ClassHasMany ===== | ===== ClassHasMany ===== | ||
- | To globally define a one-to-many relationship we use the static function | + | To globally define a one-to-many relationship we use the static function |
<code php> | <code php> | ||
Line 408: | Line 408: | ||
var_dump($p-> | var_dump($p-> | ||
</ | </ | ||
- | The solution to the above is to unset($p-> | + | The solution to the above is to |
+ | | ||
+ | before | ||
+ | | ||
===== TableHasMany ===== | ===== TableHasMany ===== | ||
Line 425: | Line 428: | ||
<code php> | <code php> | ||
- | $db-> | + | $db-> |
- | $db-> | + | |
- | $db-> | + | $db-> |
+ | values (1,' | ||
+ | $db-> | ||
+ | values (1,' | ||
class person extends ADOdb_Active_Record{} | class person extends ADOdb_Active_Record{} | ||
Line 438: | Line 444: | ||
$person-> | $person-> | ||
- | $person2 = new person(); # no need to define HasMany() again, adodb remembers definition | + | /* |
+ | * no need to define HasMany() again, adodb remembers definition | ||
+ | */ | ||
+ | $person2 = new person(); | ||
$person2-> | $person2-> | ||
$c = $person2-> | $c = $person2-> | ||
- | if (is_array($c) && sizeof($c) == 3 && $c[0]-> | + | if (is_array($c) |
- | && $c[2]-> | + | && sizeof($c) == 3 |
+ | && $c[0]-> | ||
+ | && $c[1]-> | ||
+ | && $c[2]-> | ||
+ | | ||
else { | else { | ||
- | echo "Error loading hasMany should have 3 array elements Jill Joan Jamie< | + | echo "Error loading hasMany should have |
+ | | ||
} | } | ||
</ | </ | ||
Line 483: | Line 497: | ||
===== ClassBelongsTo ===== | ===== ClassBelongsTo ===== | ||
- | You can define the parent of the current object using ADODB_Active_Record: | + | You can define the parent of the current object using [[activerecord: |
<code php> | <code php> | ||
class kid extends ADOdb_Active_Record{}; | class kid extends ADOdb_Active_Record{}; |
v5/activerecord/active_record_tutorial.txt · Last modified: 2022/06/09 18:37 by 3.83.52.90