Mysql query to SQLBuilder
ur help will result in some cool extensions being build. I know u want cool extensions right :P
I need to optimize 3 calls to the database with just one call. I know i have to use the JOIN statement for this. here are the 3 calls
I need to optimize 3 calls to the database with just one call. I know i have to use the JOIN statement for this. here are the 3 calls
$sql = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$sql->SetMainTable('Discussion','d');
$sql->AddSelect(array('Name','AuthUserID','Closed','DateCreated','CountComments' ), 'd');
$sql->AddWhere('d','DiscussionID','',$DiscussionID,'=');
$result = $this->Context->Database->Select($sql, $this->Name, 'DiscussionStuff', 'An error occurred while listing the discussion information.');
$Discussion = $this->Context->Database->GetRow($result);
$sql->Clear();
$sql->SetMainTable('User','u');
$sql->AddSelect('Name', 'u');
$sql->AddWhere('u','UserID','',$Discussion['AuthUserID'],'=');
$result = $this->Context->Database->Select($sql, $this->Name, 'GetAuthorName', 'An error occurred while listing the discussion information.');
$rows = $this->Context->Database->GetRow($result);
$Discussion['AuthUsername'] = $rows[0];
$sql->Clear();
$sql->SetMainTable('Comment','c');
$sql->AddSelect('Body', 'c');
$sql->AddWhere('c','DiscussionID','',$DiscussionID,'=');
$result = $this->Context->Database->Select($sql, $this->Name, 'GetCommentBody', 'An error occurred while listing the discussion information.');
$rows = $this->Context->Database->GetRow($result);
0
This discussion has been closed.
Comments