Hi,
Are there any full examples using Quick ORM? Specifically I am trying see an example of how relationships work in Quick. I saw the docs, but they don’t give the full context as in an example showing a handler and model object working together.
My goal is to understand in my handler, how do I retrieve my Job object and have the Company property also be populated.
My code is working to load jobs, but the company property is always empty when I dump it out despite my database having job records in the job table that are linked to company records in the company table via a Foreign Key (FK).
In my Job.cfc, I have this function loadCompany(), but how does that get called? Do I have to call that explicitly?
Here is my code:
component table="job" accessors="true" extends="quick.models.BaseEntity"{
property name="jobId" column="job_id" fieldtype="id" generator="identity";
property name="jobTitle" column="job_title";
function loadCompany() {
return hasOne( "Company" );
}
}
Here is my Company.cfc
component table="company" persistent="true" extends="quick.models.BaseEntity" {
property name="companyId" column="company_id" fieldtype="id" generator="identity";
property name="companyName" column="company_name";
property name="jobs" fieldtype="one-to-many" cfc="Job" fkcolumn="company_id" type="array";
}
Any help appreciated…