Skip to content

Instantly share code, notes, and snippets.

@joshuaadickerson
Created May 7, 2013 22:15
Show Gist options
  • Select an option

  • Save joshuaadickerson/5536600 to your computer and use it in GitHub Desktop.

Select an option

Save joshuaadickerson/5536600 to your computer and use it in GitHub Desktop.
<?php
function toggleTopicSticky($topics)
{
global $smcFunc;
$topics = is_array($topics) ? $topics : array($topics);
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET is_sticky = CASE WHEN is_sticky = 1 THEN 0 ELSE 1 END
WHERE id_topic IN ({array_int:sticky_topic_ids})',
array(
'sticky_topic_ids' => $topics,
)
);
return $smcFunc['db_affected_rows']();
}
@joshuaadickerson

Copy link
Copy Markdown
Author

I verify that this can be used by anyone for any purpose without attribution

@norv

norv commented May 8, 2013

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment