Welcome Guest, Not a member yet? Register   Sign In
Profiler says 64 Queries being run. is that too high? should i be worried?
#4

[eluser]Xeoncross[/eluser]
[quote author="Latavish" date="1224792013"]I have been putting it off but i'm guessing this is the time to master the whole "left join" thing.[/quote]

lol, I know what you mean - I put it off until I started working on CXPDO and had to deal with left joins. If you download that package and set the $return value to true - you can see how LEFT, INNER, and RIGHT queries are formed.

i.e.

Code:
<?php
// Get all books from a USER with the ID of 23
// Also get data about his group!

$data['tables'] = 'users';
$data['join'][] = array(
    'type' => 'LEFT',
    'table'    => 'groups',    
    'conditions' => array('user.id' => 'groups.user_id')
}
$data['join'][] = array(
    'type' => 'LEFT',
    'table'    => 'books',    
    'conditions' => array('user.id' => 'books.user_id')
}
$data['conditions'] = array('id' => 23);

//Other things
//$data['group'] = NULL/Array
//$data['order'] = NULL/Array
//$data['limit'] = NULL/INT/String
//$data['offset'] = NULL/INT/String
//$data['columns'] = NULL/Array

print $db->select($data, TRUE);
?>

You don't need to actually use the package - but it will show you how to make valid MySQL and/or SQLite JOIN queries.


Messages In This Thread
Profiler says 64 Queries being run. is that too high? should i be worried? - by El Forum - 10-23-2008, 09:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB