SQL Select

Nabeel,

I am using the command DB::get_row($query) to run a query on the database but it seems to limit the number of times I can run it on one page view to four… 

Does this make any sense to you… after the fourth call it always comes back empty…

I can make it work using a standard sql select from the tpl file but do not want to do that..

you can see what I mean at the link below then click on KBOS

http://www.simpilotgroup.com/dev/index.php/RealSchedule

Here is the snippet

public function get_next_flight($aircraft, $location)  {
        $query = "SELECT * FROM ".TABLE_PREFIX."schedules WHERE aircraft='$aircraft' AND depicao='$location'";

        return DB::get_row($query);
    }

You should probably use get_results() to return them all. What are you trying to do?

A way to debug..

Change to:

$result = DB::get_row($query);
DB::debug();
return $result;

If you add the debug in, I’ll check out the page, it might give some clue as to what’s up

I will try that and see what I get.

I am building a aircraft placement and fight system for my va and with that function I only need one row out of the schedules table, I used get_row to avoid having two flights show up for the same aircraft just in case there were two in the db.

Back to it  8)

I will try that and see what I get.

I am building a aircraft placement and fight system for my va and with that function I only need one row out of the schedules table, I used get_row to avoid having two flights show up for the same aircraft just in case there were two in the db.

Back to it  8)

Gotcha. I would add a LIMIT 1 and a ORDER BY column ASC/DESC so you can select which one in case there are multiples.

You can also do one query with get_results() by using GROUP BY aircraft, it will return one result row for each aircraft. Check out the stats functions for examples of that, but it might be more efficient.