Welcome Guest, Not a member yet? Register   Sign In
Help rewriting sql line please
#1

[eluser]RJ[/eluser]
Code:
$sel = "SELECT * FROM wptransactions WHERE active='y' AND (ifind_msisdn = '".$this->msisdn."' or m_tt_msisdn='".$this->msisdn."' or trimtrac_msisdn = '".$this->msisdn."')";

I have
Code:
$arr = array(ifind_msisdn,m_tt_msisdn,trimtrac_msisdn);
$this->db->select('*')->from('wptransactions')->where('active', 'y')->and('$arr', $this->msisdn);

But I know that's not right. Any thoughts?

Thank you!

Edit:
actually i could use help with this one as well ;|
Code:
$sel = "SELECT devicetype, TO_CHAR(subversion) FROM ttdevice WHERE msisdn = '".$MSISDN."' AND unitid = '".$UNITID."'";

The TO_CHAR I'm not sure who to build string including that.
#2

[eluser]Armchair Samurai[/eluser]
Number one
Code:
$msisdn = $this->db->escape($this->msisdn);

$this->db->where('active', 'y');
$this->db->where("(
    ifind_msisdn = $msisdn
    OR m_tt_msisdn = $msisdn
    OR trimtrac_msisdn = $msisdn
)", NULL, FALSE);
$query = $this->db->get('wptransactions');

Number two
Code:
$this->db->select('devicetype');
$this->db->select('TO_CHAR(subversion)', FALSE);
$this->db->where(array(
    'msidn' => $MSISDN,
    'unitid' => $UNITID
));
$query = $this->db->get('ttdevice');
#3

[eluser]RJ[/eluser]
love the signature! thanks, very much appreciated.
#4

[eluser]RJ[/eluser]
Hey I'm getting this error when running the second query.
Quote:Fatal error: Call to undefined method Shop::_remove_invisible_characters() in D:\data\Inetpub\wwwweb_verynew\s\system\database\drivers\odbc\odbc_driver.php on line 248

Any idea why? I changed the code slightly to reflect correct database:
Code:
$TT = $this->load->database('trimtrac', TRUE);
        $TT->select('devicetype');
        $TT->select('TO_CHAR(subversion)', FALSE);
        $TT->where(array(
            'msidn' => $this->MSISDN,
            'unitid' => $this->UNITID
        ));
        $query = $TT->get('ttdevice');

        if (empty($query))
        {
            return false;
            log_message('error', 'Can not locate MSISDN and UnitID in our system');
        }
        else
        {
            if ($query->num_rows() > 0)
            {
                foreach ($query->result() as $row)
                {
                  var_dump($row);
                }
            }
        }

Not sure why its erroring on a non-existing method, this is the odbc driver code, erroring on the return line:
Code:
function escape_str($str)    
    {
        // Access the CI object
        $CI =& get_instance();

        // ODBC doesn't require escaping
        return $CI->_remove_invisible_characters($str);
    }
#5

[eluser]RJ[/eluser]
Commented out the return line, changed to true. not sure what negative effect that could have, but the error is non-existent.
#6

[eluser]RJ[/eluser]
Moved thread to this discussion, can not get values into where statement; only '1'??

http://ellislab.com/forums/viewthread/111949/




Theme © iAndrew 2016 - Forum software by © MyBB