# |
Feb 4th 2018, 01:50 |
ricksaccous |
i always just define associations in the table model itself |
# |
Feb 4th 2018, 01:50 |
ricksaccous |
to be honest i've never used the join method |
# |
Feb 4th 2018, 01:49 |
itamer |
aah, no, scratch that, toArray() also shows the wrong data, as if the joins are being ignored at run time even though the sql shows it |
# |
Feb 4th 2018, 01:47 |
itamer |
even though I see the sql when I debug $query somehow the records that get returned have the joins stripped off. Does that sound right? |
# |
Feb 4th 2018, 01:46 |
itamer |
@ricksaccous, if you're still around. I'm running findAuth to extend the rules on the records that get returned |
# |
Feb 4th 2018, 01:19 |
ricksaccous |
I had no idea where to begin debugging, was going to suggest possible foul play in the callback methods |
# |
Feb 4th 2018, 01:19 |
ricksaccous |
@itamer nice, glad you got it working |
# |
Feb 4th 2018, 01:18 |
itamer |
@ricksaccous somehow I just fixed it, been chasing my tail on this for hours. very frustrating. |
# |
Feb 4th 2018, 01:16 |
slackebot |
DESC', |
# |
Feb 4th 2018, 01:16 |
itamer |
'sql' => 'SELECT Individuals.id AS `Individuals__id`, Individuals.email AS `Individuals__email`, Individuals.password AS `Individuals__password` FROM individuals Individuals INNER JOIN memberships Memberships ON Individuals.membership_id = Memberships.id INNER JOIN finances Finances ON Finances.membership_id = :c0 WHERE (Individuals.email = :c1 AND Individuals.status in (:c2,:c3) AND Memberships.softdelete = :c4) ORDER BY Finances.enddate |
# |
Feb 4th 2018, 01:16 |
itamer |
but if I get the sql and paste it direct into the database (and tidy up the variables) I get the right data |
# |
Feb 4th 2018, 01:16 |
itamer |
that's right |
# |
Feb 4th 2018, 01:14 |
ricksaccous |
so you do a debug on $user after this and it's null? |
# |
Feb 4th 2018, 01:13 |
itamer |
yep, there are 3 records that match for the email I'm testing with, I want the first one |
# |
Feb 4th 2018, 01:13 |
ahmed_bodi |
exactly as i needed it to |
# |
Feb 4th 2018, 01:12 |
ahmed_bodi |
the core of the issue was actually using varchar's for the id's due to an auth plugin i had used prior, but removed all the old crap and convertedit all back to int's and now all works great |
# |
Feb 4th 2018, 01:12 |
ricksaccous |
@itamer ->first only returns one result.. how are you getting null? what returns null exactly? that code you posted? |
# |
Feb 4th 2018, 01:11 |
ahmed_bodi |
i finally got it |
# |
Feb 4th 2018, 01:11 |
ahmed_bodi |
@hmic your awesome |
# |
Feb 4th 2018, 00:45 |
slackebot |
, 'conditions' => ['Memberships.id' => 'Individuals.membership_id'] ] , 'Finances' => [ 'table' => 'finances' , 'type' => 'INNER' , 'conditions' => ['Finances.membership_id' => 'Memberships.id'] ]]) ->order(['Finances.enddate' => 'DESC']) ->first(); |
# |
Feb 4th 2018, 00:45 |
itamer |
$user = $this->find() ->select(['Individuals.id', 'Individuals.email', 'Individuals.password', 'Finances.enddate']) ->where([ 'Individuals.email' => $email , 'Individuals.status IN' => ['g','m'] , 'Memberships.softdelete' => 'N' ]) ->join([ 'Memberships' => [ 'table' => 'memberships' , 'type' => 'INNER' |
# |
Feb 4th 2018, 00:45 |
itamer |
aargh, I just broke something. I'll past the code below. It's in a table file, if I debug to get the query and run it I get 3 results. but the cake3 query returns null. Any ideas? |
# |
Feb 4th 2018, 00:44 |
ahmed_bodi |
:) |
# |
Feb 4th 2018, 00:44 |
popperz0r |
thanks |
# |
Feb 4th 2018, 00:44 |
popperz0r |
yep! :P |
# |
Feb 4th 2018, 00:43 |
popperz0r |
content type json? |
# |
Feb 4th 2018, 00:43 |
popperz0r |
https://book.cakephp.org/3.0/en/views/json-and-xml-views.html#creating-json-views |
# |
Feb 4th 2018, 00:43 |
popperz0r |
its on the docs |
# |
Feb 4th 2018, 00:43 |
popperz0r |
```// View code - src/Template/Articles/json/index.ctp foreach ($articles as and$article) { unset($article->generated_html);``` |
# |
Feb 4th 2018, 00:42 |
popperz0r |
nono |
# |
Feb 4th 2018, 00:41 |
ahmed_bodi |
.json extension? |
# |
Feb 4th 2018, 00:40 |
popperz0r |
why does some of my ajax auto trigger /json view files and some dont? |
# |
Feb 4th 2018, 00:40 |
popperz0r |
i also have a json doubt :) |
# |
Feb 4th 2018, 00:30 |
hippo |
Anyone here using CRUD JSONAPI? |
# |
Feb 4th 2018, 00:18 |
ahmed_bodi |
i've got the user's primary key id's in the referrer_id fields where the links are supposed to be |
# |
Feb 4th 2018, 00:18 |
ahmed_bodi |
@hmic, ok so ive mapped parent_id to my referrer_id field, and ive added the lft and rght fields. I've also run users->recover() and none of the fields are becoming populated so now im lost |
# |
Feb 4th 2018, 00:08 |
ahmed_bodi |
parent_id i imaging in my case would be referrer_id |
# |
Feb 4th 2018, 00:06 |
hmic |
;-) |
# |
Feb 4th 2018, 00:06 |
hmic |
which can be used to build the tree initially from existing data |
# |
Feb 4th 2018, 00:06 |
hmic |
parent_id is already there - might be different name |
# |
Feb 4th 2018, 00:06 |
ahmed_bodi |
will give it a shot sure |