simple left join mystery

simple left join mystery

stenbergstenberg Posts: 10Questions: 2Answers: 0

Hello,

I have a few projects built now with simple left joins following the example on the web site.

This latest project, built the same way, has a problem I have not encountered before. What happened after I added the new column, which is country name, is, I get back invalid json which is simply empty. There are no errors on either the javascript console or on server side logs like I would normally expect.

In fact, I enabled the mysql log and the join is working correctly, as well as the unique select after it to fetch a list of all countries.

So, the mysql, apache, and console logs all show no clue. The sql executed on the server is returning all the rows expected but they vanish.

Latest version of datatables editor purchased recently and all similar projects work. The Field that breaks the whole thing looks like this:

Field::inst('users.country')
->options(Options::inst()
->table('countries')
->value('id')
->label('country')
)
->validator('Validate::dbValues'),

As soon as I remove that my project works again. The join is simply:

leftJoin( 'countries', 'countries.id', '=', 'users.country' )

So I can leave the join and the linked table field which follows but if I put back the code above my project silently breaks.

I'm kinda lost now where to start because previously all errors were easy to trace down by looking at either the js console, the apache error log, or the json packet but here I have nothing.

Replies

  • stenbergstenberg Posts: 10Questions: 2Answers: 0

    UPDATE: solved it myself. :-)

    I started wondering if the issue was specific to the table "countries" itself, and noticed that in the config file I did not have the recommended "dsn" => "charset=utf8"

    Adding that instantly solved the issue.

  • allanallan Posts: 63,302Questions: 1Answers: 10,431 Site admin

    Fantastic - great to hear you have found a solution. Thanks for posting back.

    Regards,
    Allan

This discussion has been closed.