Active write codeigniter and mysql

I run a query with an active entry in the modal application of my code dictionary, the query looks like this:

public function selectAllJobs()
{
    $this->db->select('*')
             ->from('job_listing')
             ->join('job_listing_has_employer_details', 'job_listing_has_employer_details.employer_details_id = job_listing.id', 'left');
             //->join('employer_details', 'employer_details.users_id = job_listing_has_employer_details.employer_details_id');

    $query = $this->db->get();
    return $query->result_array();
}

Returns an array that looks like this:

    [0]=>
  array(13) {
    ["id"]=>
    string(1) "1"
    ["job_titles_id"]=>
    string(1) "1"
    ["location"]=>
    string(12) "Huddersfield"
    ["location_postcode"]=>
    string(7) "HD3 4AG"
    ["basic_salary"]=>
    string(19) "£20,000 - £25,000"
    ["bonus"]=>
    string(12) "php, html, j"
    ["benefits"]=>
    string(11) "Compnay Car"
    ["key_skills"]=>
    string(1) "1"
    ["retrain_position"]=>
    string(3) "YES"
    ["summary"]=>
    string(73) "Lorem Ipsum is simply dummy text of the printing and typesetting industry"
    ["description"]=>
    string(73) "Lorem Ipsum is simply dummy text of the printing and typesetting industry"
    ["job_listing_id"]=>
    NULL
    ["employer_details_id"]=>
    NULL
  }
}

Jobs job_listing_id and employeeer_details_id are returned as NULL, however, if I run SQL in phpmyadmin, I get a full set of results, the query that I run in phpmyadmin,

    SELECT *
FROM (
`job_listing`
)
LEFT JOIN `job_listing_has_employer_details` ON `job_listing_has_employer_details`.`employer_details_id`
LIMIT 0 , 30

Is there a reason why I get different results?

+3
source share
1 answer

Run $ this-> db-> last_query () and check the difference. This is a very useful debugging tool.

Of course, the limit will have an effect, but I ignore it.

phpmyadmin, 'ON' . , phpmyadmin :

SELECT *
FROM (
`job_listing`
)
LEFT JOIN `job_listing_has_employer_details` ON `job_listing_has_employer_details`.`employer_details_id` =  = `job_listing`.`id`

result_array, , .

+3

Source: https://habr.com/ru/post/1748755/


All Articles