[ticket/12060] Use $sql_ary instead of $sql

PHPBB3-12060
This commit is contained in:
Matt Friedman 2013-12-12 13:50:13 -08:00
parent b6eb1f66e1
commit 6ccec39e43
2 changed files with 20 additions and 16 deletions

View file

@ -342,24 +342,26 @@ class acp_bbcodes
'U_ACTION' => $this->u_action . '&action=add', 'U_ACTION' => $this->u_action . '&action=add',
); );
$sql = 'SELECT * $sql_ary = array(
FROM ' . BBCODES_TABLE . ' 'SELECT' => 'b.*',
ORDER BY bbcode_tag'; 'FROM' => array(BBCODES_TABLE => 'b'),
'ORDER_BY' => 'b.bbcode_tag',
);
/** /**
* Modify bbcode template data before we display the form * Modify bbcode template data before we display the form
* *
* @event core.acp_bbcodes_display_form * @event core.acp_bbcodes_display_form
* @var string action Type of the action: modify|create * @var string action Type of the action: modify|create
* @var string sql SQL statement to get bbcode data * @var string sql_ary The SQL array to get custom bbcode data
* @var array template_data Array with form template data * @var array template_data Array with form template data
* @var object this_u_action $this->u_action object * @var object this_u_action $this->u_action object
* @since 3.1-A3 * @since 3.1-A3
*/ */
$vars = array('action', 'sql', 'template_data', 'this_u_action'); $vars = array('action', 'sql_ary', 'template_data', 'this_u_action');
extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_form', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_form', compact($vars)));
$result = $db->sql_query($sql); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
$template->assign_vars($template_data); $template->assign_vars($template_data);
@ -387,7 +389,7 @@ class acp_bbcodes
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$this->u_action = $this_u_action; $this->u_action = $this_u_action;
} }

View file

@ -928,22 +928,24 @@ function display_custom_bbcodes()
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing) // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
$num_predefined_bbcodes = 22; $num_predefined_bbcodes = 22;
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline $sql_ary = array(
FROM ' . BBCODES_TABLE . ' 'SELECT' => 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline',
WHERE display_on_posting = 1 'FROM' => array(BBCODES_TABLE => 'b'),
ORDER BY bbcode_tag'; 'WHERE' => 'b.display_on_posting = 1',
'ORDER_BY' => 'b.bbcode_tag',
);
/** /**
* Modify the SQL statement retrieving the custom bbcodes * Event to modify the SQL query before custom bbcode data is queried
* *
* @event core.display_custom_bbcodes_modify_sql * @event core.display_custom_bbcodes_modify_sql
* @var string sql SQL SELECT statement * @var array sql_ary The SQL array to get the bbcode data
* @since 3.1-A3 * @since 3.1-A3
*/ */
$vars = array('sql'); $vars = array('sql_ary');
extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_sql', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_sql', compact($vars)));
$result = $db->sql_query($sql); $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
$i = 0; $i = 0;
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
@ -963,7 +965,7 @@ function display_custom_bbcodes()
); );
/** /**
* Modify the template data block of a bbcode * Event to modify the template data block of a custom bbcode
* *
* This event is triggered once per bbcode * This event is triggered once per bbcode
* *