Created
November 14, 2019 09:48
-
-
Save remoharsono/5e18d0194a4d8381901a9bab64084d58 to your computer and use it in GitHub Desktop.
PHP ADOdb Active Record - One to Many
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('adodb/adodb.inc.php'); | |
include('adodb/adodb-active-record.inc.php'); | |
$driver = 'mysqli'; | |
$server = 'localhost'; | |
$user = 'root'; | |
$password = 'secret'; | |
$database = 'mydb'; | |
$db = newAdoConnection($driver); | |
$db->pConnect($server, $user, $password, $database); | |
ADOdb_Active_Record::SetDatabaseAdapter($db); | |
class person extends ADOdb_Active_Record{} | |
ADODB_Active_Record::ClassHasMany('person', 'children','person_id'); | |
$tblOrtu = 'persons'; | |
$person = new person($tblOrtu); | |
$person->Load("id=1"); | |
foreach($person->children as $c) { | |
echo " $c->nama \n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment