Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
SqlBuilder Problem
function MakeFileAfterNewComment($Context) {
$Comment = $Context->DelegateParameters['Comment'];
if($Comment->WhisperUserID == false) {
// Init SqlBuilder
$s = $Context->ObjectFactory->NewContextObject($Context, 'SqlBuilder');
// Get the Discussion Name
$DiscussionID = $Comment->DiscussionID;
$s->SetMainTable('Discussion', 'd');
$s->AddSelect('Name', 'd');
$s->AddWhere('d', 'DiscussionID', '', $DiscussionID, '=');
$DiscussionName = $this->Context->Database->Execute($s, $Comment, '', 'An error occurred while finding a Discussion name.');
}
}
$Context->AddToDelegate('CommentManager','PreSaveNewComment','MakeFileAfterNewComment');
From that i get this...
Fatal error: Call to a member function SetMainTable() on a non-object in C:\Server\htdocs\Vanilla\extensions\Flash Updator\default.php on line 21
Any help? I'm trying to learn how to use the sqlbuilder...
0
This discussion has been closed.
Comments
Try this:
function MakeFileAfterNewComment($CommentManager) { $Comment = $CommentManager->Context->DelegateParameters['Comment']; if($Comment->WhisperUserID == false) { // Init SqlBuilder $s = $CommentManager->Context->ObjectFactory->NewContextObject($Context, 'SqlBuilder'); // ... $DiscussionName = $CommentManager->Context->Database->Execute($s, $Comment, '', 'An error occurred while finding a Discussion name.');
Also, WallPhone missed one context reference. It should always be accessed through the object that was passed into the function:
function MakeFileAfterNewComment(&$CommentManager) { $Comment = $CommentManager->Context->DelegateParameters['Comment']; if ($Comment->WhisperUserID == false) { // Init SqlBuilder $s = $CommentManager->Context->ObjectFactory->NewContextObject($CommentManager->Context, 'SqlBuilder'); // Get the Discussion Name $DiscussionID = $Comment->DiscussionID; $s->SetMainTable('Discussion', 'd'); $s->AddSelect('Name', 'd'); $s->AddWhere('d', 'DiscussionID', '', $DiscussionID, '='); $DiscussionName = $CommentManager->Context->Database->Execute($s, $Comment, '', 'An error occurred while finding a Discussion name.'); } } $Context->AddToDelegate('CommentManager','PreSaveNewComment','MakeFileAfterNewComment');
Notice: Undefined property: Context::$DelegateParameters in ...\Vanilla\extensions\Flash Updator\default.php on line 12 Notice: Trying to get property of non-object in ...\Vanilla\extensions\Flash Updator\default.php on line 13 Notice: Trying to get property of non-object in ...\Vanilla\extensions\Flash Updator\default.php on line 19 Catchable fatal error: Object of class SqlBuilder could not be converted to string in ...\Vanilla\library\Framework\Framework.Class.MySQL.php on line 37
Well, that's what i get.... is something wrong here?
function MakeFileAfterNewComment(&$CommentManager) { $Comment = $CommentManager->DelegateParameters['Comment']; if ($Comment->WhisperUserID == false) { // Init SqlBuilder $s = $CommentManager->Context->ObjectFactory->NewContextObject($CommentManager->Context, 'SqlBuilder'); // Get the Discussion Name $DiscussionID = $Comment->DiscussionID; $s->SetMainTable('Discussion', 'd'); $s->AddSelect('Name', 'd'); $s->AddWhere('d', 'DiscussionID', '', $DiscussionID, '='); $ResultSet = $CommentManager->Context->Database->Select($s, $Comment, '', 'An error occurred while finding a Discussion name.'); } } $Context->AddToDelegate('CommentManager','PreSaveNewComment','MakeFileAfterNewComment');
This'll help me when i confront the RSS addon...