Topic: What is faster?
I now have this code:
case 'process':
$query = array (
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_script']).'\'', 'WHERE' => 'conf_name= \'o_gallery_script\'' ),
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_show_bbcode']).'\'', 'WHERE' => 'conf_name= \'o_gallery_show_bbcode\'' ),
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_upload_size']).'\'', 'WHERE' => 'conf_name= \'o_gallery_upload_size\'' ),
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_upload_dir']).'\'', 'WHERE' => 'conf_name= \'o_gallery_upload_dir\'' ),
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_allowed_extension']).'\'', 'WHERE' => 'conf_name= \'o_gallery_allowed_extension\'' ),
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_allowed_usergroups']).'\'', 'WHERE' => 'conf_name= \'o_gallery_allowed_usergroups\'' ),
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_disallowed_user']).'\'', 'WHERE' => 'conf_name= \'o_gallery_disallowed_user\'' ),
array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_allowed_upload']).'\'', 'WHERE' => 'conf_name= \'o_gallery_allowed_upload\'' )
);
foreach ( $query as $update ) {
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
require_once PUN_ROOT.'include/cache.php';
generate_config_cache ( );
redirect ( pun_link ( 'extensions/gallery/admin/gallery.php' ), $lang_gallery['update success'] );
Or is it faster if I do this?
case 'process':
if ( $_POST['o_gallery_script'] != $pun_config['o_gallery_script'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_script']).'\'', 'WHERE' => 'conf_name= \'o_gallery_script\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
if ( $_POST['o_gallery_show_bbcode'] != $pun_config['o_gallery_show_bbcode'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_show_bbcode']).'\'', 'WHERE' => 'conf_name= \'o_gallery_show_bbcode\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
if ( $_POST['o_gallery_upload_size'] != $pun_config['o_gallery_upload_size'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_upload_size']).'\'', 'WHERE' => 'conf_name= \'o_gallery_upload_size\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
if ( $_POST['o_gallery_upload_dir'] != $pun_config['o_gallery_upload_dir'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_upload_dir']).'\'', 'WHERE' => 'conf_name= \'o_gallery_upload_dir\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
if ( $_POST['o_gallery_allowed_extension'] != $pun_config['o_gallery_allowed_extension'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_allowed_extension']).'\'', 'WHERE' => 'conf_name= \'o_gallery_allowed_extension\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
if ( $_POST['o_gallery_allowed_usergroups'] != $pun_config['o_gallery_allowed_usergroups'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_allowed_usergroups']).'\'', 'WHERE' => 'conf_name= \'o_gallery_allowed_usergroups\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
if ( $_POST['o_gallery_disallowed_user'] != $pun_config['o_gallery_disallowed_user'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_disallowed_user']).'\'', 'WHERE' => 'conf_name= \'o_gallery_disallowed_user\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
if ( $_POST['o_gallery_allowed_upload'] != $pun_config['o_gallery_allowed_upload'] ) {
$query = array ( 'UPDATE' => 'config', 'SET' => 'conf_value=\''.$db->escape($_POST['o_gallery_allowed_upload']).'\'', 'WHERE' => 'conf_name= \'o_gallery_allowed_upload\'' );
$db->query_build ( $update ) or error (__FILE__, __LINE__);
}
require_once PUN_ROOT.'include/cache.php';
generate_config_cache ( );
redirect ( pun_link ( 'extensions/gallery/admin/gallery.php' ), $lang_gallery['update success'] );
I think that the first is faster because in the time that the second script has to check if $_POST and $pun_config is the same the first script is already done with it I think;
What do you all think?