ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 4122


Ignore:
Timestamp:
Sep 19, 2007, 4:48:57 PM (14 years ago)
Author:
ogawa
Message:

#1208:db/common.phpの読み込み系関数の引数にDSN名を加えた

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/trunk/webapp/lib/db/common.php

    r3738 r4122  
    5656}
    5757
    58 function db_get_one($sql, $params = array())
    59 {
    60     $reader =& db_get_instance('main_reader', true);
     58function db_get_one($sql, $params = array(), $dsn_name = 'main_reader')
     59{
     60    if ($dsn_name = 'main_reader') {
     61        $reader =& db_get_instance($dsn_name, true);
     62    } else {
     63        $reader =& db_get_instance($dsn_name);
     64    }
    6165    return $reader->get_one($sql, $params);
    6266}
    6367
    64 function db_get_row($sql, $params = array())
    65 {
    66     $reader =& db_get_instance('main_reader', true);
     68function db_get_row($sql, $params = array(), $dsn_name = 'main_reader')
     69{
     70    if ($dsn_name = 'main_reader') {
     71        $reader =& db_get_instance($dsn_name, true);
     72    } else {
     73        $reader =& db_get_instance($dsn_name);
     74    }
    6775    return $reader->get_row($sql, $params);
    6876}
    6977
    70 function db_get_col($sql, $params = array())
    71 {
    72     $reader =& db_get_instance('main_reader', true);
     78function db_get_col($sql, $params = array(), $dsn_name = 'main_reader')
     79{
     80    if ($dsn_name = 'main_reader') {
     81        $reader =& db_get_instance($dsn_name, true);
     82    } else {
     83        $reader =& db_get_instance($dsn_name);
     84    }
    7385    return $reader->get_col($sql, $params);
    7486}
    7587
    76 function db_get_col_limit($sql, $from, $count, $params = array())
    77 {
    78     $reader =& db_get_instance('main_reader', true);
     88function db_get_col_limit($sql, $from, $count, $params = array(), $dsn_name = 'main_reader')
     89{
     90    if ($dsn_name = 'main_reader') {
     91        $reader =& db_get_instance($dsn_name, true);
     92    } else {
     93        $reader =& db_get_instance($dsn_name);
     94    }
    7995    return $reader->get_col_limit($sql, $from, $count, $params);
    8096}
    8197
    82 function db_get_col_page($sql, $page, $count, $params = array())
    83 {
    84     $reader =& db_get_instance('main_reader', true);
     98function db_get_col_page($sql, $page, $count, $params = array(), $dsn_name = 'main_reader')
     99{
     100    if ($dsn_name = 'main_reader') {
     101        $reader =& db_get_instance($dsn_name, true);
     102    } else {
     103        $reader =& db_get_instance($dsn_name);
     104    }
    85105    return $reader->get_col_page($sql, $page, $count, $params);
    86106}
    87107
    88 function db_get_assoc($sql, $params = array())
    89 {
    90     $reader =& db_get_instance('main_reader', true);
     108function db_get_assoc($sql, $params = array(), $dsn_name = 'main_reader')
     109{
     110    if ($dsn_name = 'main_reader') {
     111        $reader =& db_get_instance($dsn_name, true);
     112    } else {
     113        $reader =& db_get_instance($dsn_name);
     114    }
    91115    return $reader->get_assoc($sql, $params);
    92116}
    93117
    94 function db_get_assoc_limit($sql, $from, $count, $params = array())
    95 {
    96     $reader =& db_get_instance('main_reader', true);
     118function db_get_assoc_limit($sql, $from, $count, $params = array(), $dsn_name = 'main_reader')
     119{
     120    if ($dsn_name = 'main_reader') {
     121        $reader =& db_get_instance($dsn_name, true);
     122    } else {
     123        $reader =& db_get_instance($dsn_name);
     124    }
    97125    return $reader->get_assoc_limit($sql, $from, $count, $params);
    98126}
    99127
    100 function db_get_all($sql, $params = array())
    101 {
    102     $reader =& db_get_instance('main_reader', true);
     128function db_get_all($sql, $params = array(), $dsn_name = 'main_reader')
     129{
     130    if ($dsn_name = 'main_reader') {
     131        $reader =& db_get_instance($dsn_name, true);
     132    } else {
     133        $reader =& db_get_instance($dsn_name);
     134    }
    103135    return $reader->get_all($sql, $params);
    104136}
    105137
    106 function db_get_all_limit($sql, $from, $count, $params = array())
    107 {
    108     $reader =& db_get_instance('main_reader', true);
     138function db_get_all_limit($sql, $from, $count, $params = array(), $dsn_name = 'main_reader')
     139{
     140    if ($dsn_name = 'main_reader') {
     141        $reader =& db_get_instance($dsn_name, true);
     142    } else {
     143        $reader =& db_get_instance($dsn_name);
     144    }
    109145    return $reader->get_all_limit($sql, $from, $count, $params);
    110146}
    111147
    112 function db_get_all_page($sql, $page, $count, $params = array())
    113 {
    114     $reader =& db_get_instance('main_reader', true);
     148function db_get_all_page($sql, $page, $count, $params = array(), $dsn_name = 'main_reader')
     149{
     150    if ($dsn_name = 'main_reader') {
     151        $reader =& db_get_instance($dsn_name, true);
     152    } else {
     153        $reader =& db_get_instance($dsn_name);
     154    }
    115155    return $reader->get_all_page($sql, $page, $count, $params);
    116156}
Note: See TracChangeset for help on using the changeset viewer.