• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MOVED - When passing variable to DB statement value is changing


Having a problem, when I set class variables from input and print the results they are as expected:
$this->MSISDN = $this->input->post('MSISDN');
$this->UNITID = $this->input->post('UNITID');


But when I add those to the query below the values are changed to '1'??
$TT->select('TO_CHAR(subversion)', FALSE);
            'msisdn' => $this->input->post('MSISDN'),
            'unitid' => $this->UNITID
$query = $TT->get('ttdevice');

Even when I try directly from post, the result is below:
Quote:SELECT devicetype, TO_CHAR(subversion)
FROM (ttdevice)
WHERE msisdn = '1'
AND unitid = '1'

Any idea why this is occurring and how to fix?

Thank you.

The only way I can get something other than '1' to pass is by hard coding like below:
            'msisdn' => 123456,
            'unitid' => $this->UNITID

Note no '123456' quotes around the numbers, if there are quotes it doesn't work; other variations of the query I've tried with the same result:
//Active Record Method Chaining
$TT->select('devicetype')->select('TO_CHAR(subversion)', FALSE)->where('msisdn', $this->MSISDN)->where('unitid', $this->UNITID);

// remove the where array
$TT->select('TO_CHAR(subversion)', FALSE);
$TT->where('msisdn', $this->MSISDN);
$TT->where('unitid', $this->UNITID);

I settled with this query:
$query = $TT->query("SELECT devicetype, TO_CHAR(subversion) FROM ttdevice WHERE msisdn = '".$this->MSISDN."' AND unitid = '".$this->UNITID."'");

Just can't get the damn thing to return any results.

Submitting now
$query = $TT->query("SELECT * FROM ttdevice");

the result is -1. I know the db is there, am i missing something?

Object results
Quote:CI_DB_odbc_result Object ( [conn_id] => Resource id #123 [result_id] => Resource id #124 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => -1 [row_data] => )

What does the profiler reveal about your actual query?

I can recommend formatting your ->query stuff to make it more readable - syntax bugs stand out much more obviously, eg.
$query = $this->db->query ("SELECT  message.id AS message_id,
                                            member.login_name AS addressee_name,
                                            member.login_name as author_name
                                        LEFT JOIN
                                            member ON message.author=member.id
                                            addressee=". $my_id ."
                                        ORDER BY
                                            message.msgdate DESC
                                        LIMIT ". $offset ." , ". $count );

Btw, been meaning to ask for some time, but is the misspelling in your sig some post-modern or ironical reference to enjoying bad-writing?

In all instances the profiler will not display the odbc query, not sure why. I am using multiple databases, default is an sql that does show up in the profiler; when I run this other query, which is a form_validation callback method, it does not show.

I moved the thread to here when I finally was able to find the results.. num_rows check is screwing it all up. http://ellislab.com/forums/viewthread/111959/

Good suggestion.

Nope, user error! LOL, thanks!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.