Ignore:
Timestamp:
May 30, 2006 9:30:35 PM (18 years ago)
Author:
scdev
Message:

finished updating DB:: to $db->

Location:
branches/2.0singleton/bin/module_maker
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0singleton/bin/module_maker/form_template.cli.php

    r127 r130  
    1717
    1818// Get DB tables.
    19 $qid = DB::query("SHOW TABLES");
     19$qid = $db->query("SHOW TABLES");
    2020while (list($row) = mysql_fetch_row($qid)) {
    2121    $tables[] = $row;
     
    2828
    2929// Get DB table column info.
    30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     30$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    3131while ($row = mysql_fetch_row($qid)) {
    3232    $cols[] = $row;
  • branches/2.0singleton/bin/module_maker/list_template.cli.php

    r127 r130  
    3030
    3131// Get DB tables.
    32 $qid = DB::query("SHOW TABLES");
     32$qid = $db->query("SHOW TABLES");
    3333while (list($row) = mysql_fetch_row($qid)) {
    3434    $tables[] = $row;
     
    4141
    4242// Get DB table column info.
    43 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     43$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    4444while ($row = mysql_fetch_row($qid)) {
    4545    $cols[] = $row;
  • branches/2.0singleton/bin/module_maker/module.cli.php

    r127 r130  
    129129
    130130// Get DB tables.
    131 $qid = DB::query("SHOW TABLES");
     131$qid = $db->query("SHOW TABLES");
    132132while (list($row) = mysql_fetch_row($qid)) {
    133133    $tables[] = $row;
     
    141141// Ensure requested table contains columns.
    142142// Get DB table column info.
    143 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     143$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    144144while ($row = mysql_fetch_row($qid)) {
    145145    $cols[] = $row;
  • branches/2.0singleton/bin/module_maker/skel/admin.php

    r127 r130  
    146146        if (getFormdata('repeat', false)) {
    147147            // Display edit function with next available ID.
    148             $qid = DB::query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");
     148            $qid = $db->query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");
    149149            if (list($next_id) = mysql_fetch_row($qid)) {
    150150                $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);
     
    207207{
    208208    global $lock;
    209 
     209    $db =& DB::getInstance();
     210   
    210211    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    211212    if ($lock->isLocked() && !$lock->isMine()) {
     
    214215
    215216    // Get the information for the form.
    216     $qid = DB::query("
     217    $qid = $db->query("
    217218        SELECT *
    218219        FROM %DB_TBL%
    219         WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
     220        WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
    220221    ");
    221222    if (!$frm = mysql_fetch_assoc($qid)) {
     
    246247{
    247248    global $lock;
    248 
     249    $db =& DB::getInstance();
     250   
    249251    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    250252    if ($lock->isLocked() && !$lock->isMine()) {
     
    256258
    257259    // Get the information for this object.
    258     $qid = DB::query("
     260    $qid = $db->query("
    259261        SELECT <##>
    260262        FROM %DB_TBL%
    261         WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
     263        WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
    262264    ");
    263265    if (! list($name) = mysql_fetch_row($qid)) {
     
    268270
    269271    // Delete the record.
    270     DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'");
     272    $db->query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'");
    271273
    272274    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
     
    279281{
    280282    global $auth;
    281 
     283    $db =& DB::getInstance();
     284   
    282285    // Break the cache because we are changing the list data.
    283286    SessionCache::breakCache($_SERVER['PHP_SELF']);
    284287
    285288%INSERT%
    286     $last_insert_id = mysql_insert_id(DB::getDBH());
     289    $last_insert_id = mysql_insert_id($db->getDBH());
    287290
    288291    // Create version.
     
    323326    global $page;
    324327    global $so;
    325 
     328    $db =& DB::getInstance();
     329   
    326330    $where_clause = '';
    327331
     
    336340    if (getFormData('filter_<##>', false)) {
    337341        // Limit by filter.
    338         $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . DB::escapeString(getFormData('filter_<##>')) . "'";
     342        $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . $db->escapeString(getFormData('filter_<##>')) . "'";
    339343    }
    340344
    341345    // Count the total number of records so we can do something about the page numbers.
    342     $qid = DB::query("
     346    $qid = $db->query("
    343347        SELECT COUNT(*)
    344348        FROM %DB_TBL%
     
    381385    } else {
    382386        // If the list is not already cached, query now.
    383         $qid = DB::query($sql);
     387        $qid = $db->query($sql);
    384388        // Fill an array with the items for this page.
    385389        while ($row = mysql_fetch_assoc($qid)) {
     
    398402function updateRank($ranks)
    399403{
     404    $db =& DB::getInstance();
     405   
    400406    if (!is_array($ranks)) {
    401407        $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
     
    416422            $unspecified_counter++;
    417423        }
    418         DB::query("
     424        $db->query("
    419425            UPDATE %DB_TBL% SET
    420                 rank = '" . DB::escapeString($new_rank) . "'
    421             WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
     426                rank = '" . $db->escapeString($new_rank) . "'
     427            WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
    422428        ");
    423429    }
  • branches/2.0singleton/bin/module_maker/skel/public.php

    r127 r130  
    3434
    3535    // Get requested record.
    36     $qid = DB::query("
     36    $qid = $db->query("
    3737        SELECT * FROM %DB_TBL%
    38         WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'
     38        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
    3939        AND publish = 'true'
    4040        <##>AND (publish_date <= CURDATE() OR publish_date = '0000-00-00')
     
    4747
    4848    // Update the hit counter for this record.
    49     DB::query("
     49    $db->query("
    5050        UPDATE %DB_TBL%
    5151        SET hit_count = hit_count + 1
    52         WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'
     52        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
    5353    ");
    5454
     
    6161    // Get the DEFAULT list.
    6262    $%NAME_SINGULAR%_list = array();
    63     $qid = DB::query("
     63    $qid = $db->query("
    6464        SELECT *
    6565        FROM %DB_TBL%
     
    7979    // Get the FEATURED list.
    8080    $featured_list = array();
    81     $qid = DB::query("
     81    $qid = $db->query("
    8282        SELECT *
    8383        FROM %DB_TBL%
     
    9292    // Get the POPULAR list.
    9393    $popular_list = array();
    94     $qid = DB::query("
     94    $qid = $db->query("
    9595        SELECT *
    9696        FROM %DB_TBL%
     
    104104    // Get the RECENT list.
    105105    $recent_list = array();
    106     $qid = DB::query("
     106    $qid = $db->query("
    107107        SELECT *
    108108        FROM %DB_TBL%
  • branches/2.0singleton/bin/module_maker/sql.cli.php

    r127 r130  
    3030
    3131// Get DB tables.
    32 $qid = DB::query("SHOW TABLES");
     32$qid = $db->query("SHOW TABLES");
    3333while (list($row) = mysql_fetch_row($qid)) {
    3434    $tables[] = $row;
     
    4646
    4747// Get DB table column info.
    48 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     48$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    4949while ($row = mysql_fetch_row($qid)) {
    5050    $cols[] = $row;
     
    7676        } else if ('added_by_user_id' == $field || 'modified_by_user_id' == $field) {
    7777            // Toggle types.
    78             $c[$field] = "'\" . DB::escapeString(\$auth->getVal('user_id')) . \"'";
     78            $c[$field] = "'\" . \$db->escapeString(\$auth->getVal('user_id')) . \"'";
    7979        } else if ('added_datetime' == $field || 'modified_datetime' == $field) {
    8080            // DB record insertion datetime.
     
    8282        } else {
    8383            // Default. Just insert data.
    84             $c[$field] = "'\" . DB::escapeString(\$frm['$field']) . \"'";
     84            $c[$field] = "'\" . \$db->escapeString(\$frm['$field']) . \"'";
    8585        }
    8686    }
     
    107107echo <<<E_O_F
    108108    // Insert record data.
    109     DB::query("
     109    \$db->query("
    110110        INSERT INTO $db_tbl (
    111111            $db_keys
     
    133133echo <<<E_O_F
    134134    // Update record data.
    135     DB::query("
     135    \$db->query("
    136136        UPDATE $db_tbl SET$key_eq_val
    137         WHERE $primary_key = '" . DB::escapeString(\$frm['$primary_key']) . "'
     137        WHERE $primary_key = '" . \$db->escapeString(\$frm['$primary_key']) . "'
    138138    ");
    139139E_O_F;
     
    148148$delim = 'WHERE';
    149149if (!empty($primary_key)) {
    150     $where_clause = "            $delim $primary_key = '\" . DB::escapeString(\$frm['$primary_key']) . \"'\n";
     150    $where_clause = "            $delim $primary_key = '\" . \$db->escapeString(\$frm['$primary_key']) . \"'\n";
    151151    $delim = 'AND';
    152152}
     
    155155        continue;
    156156    }
    157     $where_clause .= "            $delim $k = '\" . DB::escapeString(\$frm['$k']) . \"'\n";
     157    $where_clause .= "            $delim $k = '\" . \$db->escapeString(\$frm['$k']) . \"'\n";
    158158    $delim = 'AND';
    159159}
    160160echo <<<E_O_F
    161161        // Delete record data.
    162         DB::query("
     162        \$db->query("
    163163            DELETE FROM $db_tbl
    164164$where_clause        ");
     
    183183if (!isset($op) || 'search' == $op) {
    184184$search_skip_columns = array('added_datetime', 'added_by_user_id', 'modified_datetime', 'modified_by_user_id', 'publish', 'featured');
    185 $search_columns = $db_tbl . '.' . join(" LIKE '%\" . DB::escapeString(\$qry_words[\$i]) . \"%'\n                    OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns));
     185$search_columns = $db_tbl . '.' . join(" LIKE '%\" . \$db->escapeString(\$qry_words[\$i]) . \"%'\n                    OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns));
    186186echo <<<E_O_F
    187187            \$where_clause .= (empty(\$where_clause) ? 'WHERE' : 'AND') . "
    188188                (
    189                     $search_columns LIKE '%" . DB::escapeString(\$qry_words[\$i]) . "%'
     189                    $search_columns LIKE '%" . \$db->escapeString(\$qry_words[\$i]) . "%'
    190190                )
    191191            ";
  • branches/2.0singleton/bin/module_maker/validation.cli.php

    r127 r130  
    1717
    1818// Get DB tables.
    19 $qid = DB::query("SHOW TABLES");
     19$qid = $db->query("SHOW TABLES");
    2020while (list($row) = mysql_fetch_row($qid)) {
    2121    $tables[] = $row;
     
    2828
    2929// Get DB table column info.
    30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
     30$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
    3131while ($row = mysql_fetch_row($qid)) {
    3232    $cols[] = $row;
Note: See TracChangeset for help on using the changeset viewer.