Welcome Guest, Not a member yet? Register   Sign In
3 level join using AR
#5

[eluser]bretticus[/eluser]
[quote author="stevenL" date="1237086257"]Thanks for replying. Yes, its mySQL.
As I said, I am getting multiple rows per project. Can you give me more detail regarding:

Quote:You can programmatically suppress duplicate lines too.
[/quote]

Certainly...

Since the image column is the only thing that changes from one record to the next, you can simply check to see if you have the same project id. The following is a simple illustrative example:

Code:
<?php
$query = $this->db->get('MyTable');
if ($query->num_rows() > 0) {
    $last_project_id = 0;
    foreach ($query->result() as $row) {
        if ( $row->Project_ID != $last_project_id ) {
            // show new project record
        } else {
            // show the next image
        }
        $last_project_id = $row->Project_ID;
    }
}
?>

This is a little "hacky" for my tastes. You may want to let the database handle it via GROUP_CONCAT().


Messages In This Thread
3 level join using AR - by El Forum - 03-14-2009, 01:21 PM
3 level join using AR - by El Forum - 03-14-2009, 01:54 PM
3 level join using AR - by El Forum - 03-14-2009, 03:29 PM
3 level join using AR - by El Forum - 03-14-2009, 04:04 PM
3 level join using AR - by El Forum - 03-14-2009, 04:14 PM
3 level join using AR - by El Forum - 03-14-2009, 04:50 PM
3 level join using AR - by El Forum - 03-14-2009, 06:27 PM
3 level join using AR - by El Forum - 03-15-2009, 01:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB