Open dani0332 opened 7 years ago
If you tell the model that the table name in the relation is "standard_design", it will take your word for it...
$this->has_many['standard_designs'] = array(
'foreign_model' => 'standard_design_m',
'foreign_table' => 'standard_design',
'foreign_key' => 'dress_mode_id',
'local_key' => 'id'
);
So, even without those backticks, I don't think you will solve the problem.
Anyway, I had a problem in the past that made me put those backticks in there (don't ask me what problems... I don't remember), so I would have to take a deeper look at this problem.
@avenirer Yes, my table name in fact is 'standard_design'.
If you're referring to $this->has_many['standard_designs']
, I think this standarddesigns is used for **`with*`** which could be anything, right?
Anyhow, I try removing the 's' converting
from $this->has_many['standard_designs']
to $this->has_many['standard_design']
It didn't help. I am still getting this error (after putting back the back-ticks )
I would really appreciate if you could help me resolve this error.
Doing this :
$this->has_many['standard_design'] = array(
'foreign_model' => 'standard_design_m',
'foreign_key' => 'dress_mode_id',
'local_key' => 'id'
);
Added my db prefix twice.
Same result for:
$this->has_many['standard_design'] = 'standard_design_m';
(except now I also don't have my 'dress_mode_id')
I am referring to the fact that you mentioned in there the foreign_table...
Yes, I took that from your docs, that says right way , but like I said removing the 'foreign_table' didn't help me getting rid of that error. Please HELP !!
I had same problem when using postgresql. Modified to use "
instead of backticks is the correct solution. Eg. $select[] = '"'.$foreign_table.'"."'.$foreign_key.'"';
I made a simple one-many relationship and encounter an error as follows:
NOTES:
application/config/development/database.php
My models are: Dress_categories_m
Standard_design_m
I am writing this query in DressCategory Controller
It works fine with remove 'fields:price' as :
print_r($this->dc->fields('name')->with_standard_designs()->get(1));
However, I have speculated that these backticks are causing the issue:
SELECT
tdz_standard_design`.`dress_mode_id
I modify some code in MY_Model.php and resolved the issue, but I just wanted to make sure that this change that I made wont cause further issues in future, by asking you about this change. And perhaps you can give me a better solution.
In method join_temporary_results($data) I removed the highlighted backticks that resolved the issue.