SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast TheTiger's Avatar
    Join Date
    Jan 2004
    Location
    Fevik, Norway
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is wrong with this query?? Going mad!!

    Can anyone tell me way this do not work:???

    PHP Code:
    $sql 'UPDATE config SET `config_value` = "15" WHERE `config_name` = "flood_interval";'
            
    ' UPDATE config SET `config_value` = "50" WHERE `config_name` = "topics_per_page";'
            
    ' UPDATE config SET `config_value` = "15" WHERE `config_name` = "posts_per_page";'
            
    ' UPDATE config SET `config_value` = "D M d, Y g:i a" WHERE `config_name` = "default_dateformat";'
            
    ' UPDATE config SET `config_value` = "0" WHERE `config_name` = "system_timezone";'
            
    ' UPDATE config SET `config_value` = "0.1" WHERE `config_name` = "version";'
            
    ' UPDATE config SET `config_value` = "0" WHERE `config_name` = "allow_username_changes";'
            
    ' '
    I'm runing: Apache/2.0.52 (Win32) PHP/5.0.2 mysql/3.23.57

    Do I have to splitt it in to several query?
    Like this:

    PHP Code:
    $sql_1 'UPDATE config SET `config_value` = "15" WHERE `config_name` = "flood_interval"';
    $sql_2 'UPDATE config SET `config_value` = "50" WHERE `config_name` = "topics_per_page"';
    $sql_3 'UPDATE config SET `config_value` = "15" WHERE `config_name` = "posts_per_page"';
    $sql_4 'UPDATE config SET `config_value` = "D M d, Y g:i a" WHERE `config_name` = "default_dateformat"';
    $sql_5 'UPDATE config SET `config_value` = "0" WHERE `config_name` = "system_timezone"';
    $sql_6 'UPDATE config SET `config_value` = "0.1" WHERE `config_name` = "version"';
    $sql_7 'UPDATE config SET `config_value` = "0" WHERE `config_name` = "allow_username_changes"'

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    695
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Do I have to splitt it in to several query?
    Yes.

  3. #3
    SitePoint Enthusiast TheTiger's Avatar
    Join Date
    Jan 2004
    Location
    Fevik, Norway
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    way?

    phpMYadmin give me that php code for the query... And I thought I could try it....

    Is there a way to make it more effective? A way to not get the DB to get overheated... lol..

  4. #4
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    695
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    It is possible to write one rather complex update statement, but if this is an not to frequent occurrance I would not worry about using several statements (within a transaction, of course).

    Code:
    UPDATE config 
    SET config_value = case config_name 
     when 'flood_interval' then '15'
     when 'topics_per_page' then '50'
     when 'posts_per_page' then '15'
     when 'default_dateformat' then 'D M d, Y g:i a'
     when 'system_timezone' then '0'
     when 'version' then '0.1'
     when 'allow_username_changes' then '0' end 
    WHERE config_name in (
    'flood_intervalflood_interval','topics_per_page','posts_per_page',
    'default_dateformat','system_timezone','version',
    'allow_username_changes')

  5. #5
    SitePoint Enthusiast TheTiger's Avatar
    Join Date
    Jan 2004
    Location
    Fevik, Norway
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    I will play with it....

    Can you tell me where I can find info. about this topic? If you knowa good place!!

    Thanks again!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •