FROM is adding 1 to SQL.. |
Hi,
I have a problem with FROM. I am trying a join two tables, but the FROM function is adding 1 number to SQL sentences. My codes : PHP Code: $company = $ci->db->select('MUST.*, PERS.*')->from('musteriler as MUST') Output: Code: SELECT `MUST`.*, `PERS`.* FROM (`musteriler` as `MUST`, 1) INNER JOIN `ilgili_kisiler` AS `PERS` ON `PERS`.`musteri_id` = `MUST`.`id` You can see there is a 1 number in FROM ... How can I fix this ?
The first argument to get_where should be the name of the table. Fix that and see what happens.
(06-28-2018, 09:12 AM)php_rocs Wrote: @sDenizhan17, Output is from CI.
@sDenizhan17,
I prefer to do my queries this way (documentation: https://codeigniter.com/user_guide/datab...y-bindings). Maybe it will work for you. I don't know why the one is appearing in your query? $qry = "SELECT MUST.*, PERS.* FROM musteriler as MUST INNER JOIN ilgili_kisiler AS PERS ON PERS.musteri_id = MUST.id WHERE PERS.id = ?"; $val = [$person_id]; $company = $ci->db->query($qry,$val);
(07-02-2018, 02:22 AM)sDenizhan17 Wrote:(06-28-2018, 04:22 PM)dave friend Wrote: The first argument to get_where should be the name of the table. Fix that and see what happens. Your code PHP Code: ->get_where(array('PERS.id' => $person_id)); supplies only one argument. Try PHP Code: ->get_where('PERS', array('PERS.id' => $person_id)); On further consideration, you could probably do this PHP Code: $company = $ci->db I believe that select('*') in combination with the join statment will give you all fields from both tables.
(07-02-2018, 12:41 PM)dave friend Wrote:(07-02-2018, 02:22 AM)sDenizhan17 Wrote:(06-28-2018, 04:22 PM)dave friend Wrote: The first argument to get_where should be the name of the table. Fix that and see what happens. Thank you dave.. You right. I forgot write the first argument to get_where. When i write it fixed. |
Welcome Guest, Not a member yet? Register Sign In |