i was building an clinic managment/patient electronic records project based on codeigniter, and i decided to go for an orm since i have lots of relations between my db.
so i downloaded datamapper 1.8.2 and started a new codeigniter project first thing i noticed was loading time !
the codeigniter welcome page is now loading in 1sec ++ ! without any logic yet ! is this normal ? and is it acceptable ? usually ci loads in 0.002 sec on my machine but with datamapper orm its 1.06 at its best !
secound question is about relations.
i have 2 tables for example
table 1 users . i use to store all my office ppl, and there role
example(users)
|ID|name|role |
|1 |Demo|admin |
|2 |Demo|doctor |
|3 |Demo|nurse |
|4 |Demo|patient|
2nd table is visits
|id|doctor_id|patient_id|.....
|1 |2 |4 |......
so how can i setup this so that datamapper would understand that each user in users have a role, and that table visits has_one(doctors,patient) and users(doctors,patients) has_many(visits) ?
since every visit must have only one doctor and patient, yet every patient/doctor can have many visits.
current setup trial
class Visit extends DataMapper {
var $has_one = array(
'doctor' => array(
'class' => 'user',
'join_self_as' => 'doctor_id',
'other_field' => 'visit'
),
'patient' => array(
'class' => 'user',
'join_self_as' => 'patient_id',
'other_field' => 'visit'
)
);
var $has_many = array();
Users
class User extends DataMapper {
var $has_one = array();
var $has_many = array(
'visit' => array(
'class' => 'visit',
'other_field' => 'doctor_id',
'join_self_as' => 'doctor_id',
)
);
but when i try to access a doctor visit by
$u=new user(2);
$u->visit->get();
it give me error
DataMapper Error: 'doctor_id' is not a valid parent relationship for Visit. Are your relationships configured correctly?
help ?!