• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved]Model Problem

[eluser]eric cumbee[/eluser]
im not sure what is going on, i am passing an array into my model and loop through it creating or_where statements. the problem i am running into is that if i pass in a value like "Statesboro" when the query is executed the sql statement is something like this

SELECT COUNT(*) AS `numrows`
FROM (`voters`)
WHERE `reg_city` = 'S'

and then this is my model function
function count_voter($city) {
        if($city) {
           foreach($city as $row)
        $count = $this->db->count_all_results();
        return $count;

i have traced the data flowing all the way back from my view to the controller, and then the data being passed to the model from the controller, so i know for sure that the data is making it through the view and the controller with out being concatenated.

Probably $row is not an array but a string

[eluser]eric cumbee[/eluser]
just tried wrapping it in an if(is_array($city) and it is an array. so thats not the problem.

[eluser]eric cumbee[/eluser]
never mind i see what you are saying and that was indeed the problem. thank you, could you explain why it passed the first letter of the value rather an a error message.

I can't really explain it, but I know this kind of effect Smile, I believe one can also retrieve a letter from a string variable by using $string_variable[n].

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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