Welcome Guest, Not a member yet? Register   Sign In
How to avoid the string conversion
#1

[eluser]ReyPM[/eluser]
Hi, I've this code:
Code:
public function get_received() {
    $this->db
            ->select('p.*, rcp.*, msg.*')
            ->distinct()
            ->join($this->db->dbprefix('recipient') . ' rcp', 'rcp.user_id = ' . (int) $this->current_user->id)
            ->join($this->db->dbprefix('profiles') . ' p', 'p.user_id = ' . (int) $this->current_user->id)
            ->join($this->db->dbprefix('messages') . ' msg', 'msg.id = rcp.message_id')
            ->order_by('msg.date');

    return $this->db->get($this->db->dbprefix('messages'))->result();
  }
But this cause this error:
Quote:A Database Error Occurred
Error Number: 1054
Unknown column '1' in 'on clause'
SELECT DISTINCT `p`.*, `rcp`.*, `msg`.* FROM (`default_messages`) JOIN `default_recipient` rcp ON `rcp`.`user_id` = `1` JOIN `default_profiles` p ON `p`.`user_id` = `1` JOIN `default_messages` msg ON `msg`.`id` = `rcp`.`message_id` ORDER BY `msg`.`date`

Filename: /var/www/html/cmv/addons/default/modules/messages/models/messages_m.php
Line Number: 31
Because automatically convert the 1 to '1' meaning convert from INT to STRING and I don't want that, how to avoid this behaviour?
Cheers
#2

[eluser]Stefan Hueg[/eluser]
I've answered this question here:
http://ellislab.com/forums/viewthread/216302/
#3

[eluser]ReyPM[/eluser]
Hmm thx but for me that solution shouldn't work because I need the JOIN
#4

[eluser]Stefan Hueg[/eluser]
Well then write the SQL Query on your own and escape the variables safely.

There is no simple solution without having to rewrite parts of the source code.




Theme © iAndrew 2016 - Forum software by © MyBB