Changeset 130 for branches/2.0singleton/bin/module_maker
- Timestamp:
- May 30, 2006 9:30:35 PM (18 years ago)
- 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 17 17 18 18 // Get DB tables. 19 $qid = DB::query("SHOW TABLES");19 $qid = $db->query("SHOW TABLES"); 20 20 while (list($row) = mysql_fetch_row($qid)) { 21 21 $tables[] = $row; … … 28 28 29 29 // Get DB table column info. 30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));30 $qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl)); 31 31 while ($row = mysql_fetch_row($qid)) { 32 32 $cols[] = $row; -
branches/2.0singleton/bin/module_maker/list_template.cli.php
r127 r130 30 30 31 31 // Get DB tables. 32 $qid = DB::query("SHOW TABLES");32 $qid = $db->query("SHOW TABLES"); 33 33 while (list($row) = mysql_fetch_row($qid)) { 34 34 $tables[] = $row; … … 41 41 42 42 // Get DB table column info. 43 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));43 $qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl)); 44 44 while ($row = mysql_fetch_row($qid)) { 45 45 $cols[] = $row; -
branches/2.0singleton/bin/module_maker/module.cli.php
r127 r130 129 129 130 130 // Get DB tables. 131 $qid = DB::query("SHOW TABLES");131 $qid = $db->query("SHOW TABLES"); 132 132 while (list($row) = mysql_fetch_row($qid)) { 133 133 $tables[] = $row; … … 141 141 // Ensure requested table contains columns. 142 142 // Get DB table column info. 143 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));143 $qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl)); 144 144 while ($row = mysql_fetch_row($qid)) { 145 145 $cols[] = $row; -
branches/2.0singleton/bin/module_maker/skel/admin.php
r127 r130 146 146 if (getFormdata('repeat', false)) { 147 147 // 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"); 149 149 if (list($next_id) = mysql_fetch_row($qid)) { 150 150 $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id); … … 207 207 { 208 208 global $lock; 209 209 $db =& DB::getInstance(); 210 210 211 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id); 211 212 if ($lock->isLocked() && !$lock->isMine()) { … … 214 215 215 216 // Get the information for the form. 216 $qid = DB::query("217 $qid = $db->query(" 217 218 SELECT * 218 219 FROM %DB_TBL% 219 WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'220 WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "' 220 221 "); 221 222 if (!$frm = mysql_fetch_assoc($qid)) { … … 246 247 { 247 248 global $lock; 248 249 $db =& DB::getInstance(); 250 249 251 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id); 250 252 if ($lock->isLocked() && !$lock->isMine()) { … … 256 258 257 259 // Get the information for this object. 258 $qid = DB::query("260 $qid = $db->query(" 259 261 SELECT <##> 260 262 FROM %DB_TBL% 261 WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'263 WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "' 262 264 "); 263 265 if (! list($name) = mysql_fetch_row($qid)) { … … 268 270 269 271 // 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) . "'"); 271 273 272 274 $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); … … 279 281 { 280 282 global $auth; 281 283 $db =& DB::getInstance(); 284 282 285 // Break the cache because we are changing the list data. 283 286 SessionCache::breakCache($_SERVER['PHP_SELF']); 284 287 285 288 %INSERT% 286 $last_insert_id = mysql_insert_id( DB::getDBH());289 $last_insert_id = mysql_insert_id($db->getDBH()); 287 290 288 291 // Create version. … … 323 326 global $page; 324 327 global $so; 325 328 $db =& DB::getInstance(); 329 326 330 $where_clause = ''; 327 331 … … 336 340 if (getFormData('filter_<##>', false)) { 337 341 // 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_<##>')) . "'"; 339 343 } 340 344 341 345 // Count the total number of records so we can do something about the page numbers. 342 $qid = DB::query("346 $qid = $db->query(" 343 347 SELECT COUNT(*) 344 348 FROM %DB_TBL% … … 381 385 } else { 382 386 // If the list is not already cached, query now. 383 $qid = DB::query($sql);387 $qid = $db->query($sql); 384 388 // Fill an array with the items for this page. 385 389 while ($row = mysql_fetch_assoc($qid)) { … … 398 402 function updateRank($ranks) 399 403 { 404 $db =& DB::getInstance(); 405 400 406 if (!is_array($ranks)) { 401 407 $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__); … … 416 422 $unspecified_counter++; 417 423 } 418 DB::query("424 $db->query(" 419 425 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) . "' 422 428 "); 423 429 } -
branches/2.0singleton/bin/module_maker/skel/public.php
r127 r130 34 34 35 35 // Get requested record. 36 $qid = DB::query("36 $qid = $db->query(" 37 37 SELECT * FROM %DB_TBL% 38 WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'38 WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' 39 39 AND publish = 'true' 40 40 <##>AND (publish_date <= CURDATE() OR publish_date = '0000-00-00') … … 47 47 48 48 // Update the hit counter for this record. 49 DB::query("49 $db->query(" 50 50 UPDATE %DB_TBL% 51 51 SET hit_count = hit_count + 1 52 WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'52 WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' 53 53 "); 54 54 … … 61 61 // Get the DEFAULT list. 62 62 $%NAME_SINGULAR%_list = array(); 63 $qid = DB::query("63 $qid = $db->query(" 64 64 SELECT * 65 65 FROM %DB_TBL% … … 79 79 // Get the FEATURED list. 80 80 $featured_list = array(); 81 $qid = DB::query("81 $qid = $db->query(" 82 82 SELECT * 83 83 FROM %DB_TBL% … … 92 92 // Get the POPULAR list. 93 93 $popular_list = array(); 94 $qid = DB::query("94 $qid = $db->query(" 95 95 SELECT * 96 96 FROM %DB_TBL% … … 104 104 // Get the RECENT list. 105 105 $recent_list = array(); 106 $qid = DB::query("106 $qid = $db->query(" 107 107 SELECT * 108 108 FROM %DB_TBL% -
branches/2.0singleton/bin/module_maker/sql.cli.php
r127 r130 30 30 31 31 // Get DB tables. 32 $qid = DB::query("SHOW TABLES");32 $qid = $db->query("SHOW TABLES"); 33 33 while (list($row) = mysql_fetch_row($qid)) { 34 34 $tables[] = $row; … … 46 46 47 47 // Get DB table column info. 48 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));48 $qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl)); 49 49 while ($row = mysql_fetch_row($qid)) { 50 50 $cols[] = $row; … … 76 76 } else if ('added_by_user_id' == $field || 'modified_by_user_id' == $field) { 77 77 // Toggle types. 78 $c[$field] = "'\" . DB::escapeString(\$auth->getVal('user_id')) . \"'";78 $c[$field] = "'\" . \$db->escapeString(\$auth->getVal('user_id')) . \"'"; 79 79 } else if ('added_datetime' == $field || 'modified_datetime' == $field) { 80 80 // DB record insertion datetime. … … 82 82 } else { 83 83 // Default. Just insert data. 84 $c[$field] = "'\" . DB::escapeString(\$frm['$field']) . \"'";84 $c[$field] = "'\" . \$db->escapeString(\$frm['$field']) . \"'"; 85 85 } 86 86 } … … 107 107 echo <<<E_O_F 108 108 // Insert record data. 109 DB::query("109 \$db->query(" 110 110 INSERT INTO $db_tbl ( 111 111 $db_keys … … 133 133 echo <<<E_O_F 134 134 // Update record data. 135 DB::query("135 \$db->query(" 136 136 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']) . "' 138 138 "); 139 139 E_O_F; … … 148 148 $delim = 'WHERE'; 149 149 if (!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"; 151 151 $delim = 'AND'; 152 152 } … … 155 155 continue; 156 156 } 157 $where_clause .= " $delim $k = '\" . DB::escapeString(\$frm['$k']) . \"'\n";157 $where_clause .= " $delim $k = '\" . \$db->escapeString(\$frm['$k']) . \"'\n"; 158 158 $delim = 'AND'; 159 159 } 160 160 echo <<<E_O_F 161 161 // Delete record data. 162 DB::query("162 \$db->query(" 163 163 DELETE FROM $db_tbl 164 164 $where_clause "); … … 183 183 if (!isset($op) || 'search' == $op) { 184 184 $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)); 186 186 echo <<<E_O_F 187 187 \$where_clause .= (empty(\$where_clause) ? 'WHERE' : 'AND') . " 188 188 ( 189 $search_columns LIKE '%" . DB::escapeString(\$qry_words[\$i]) . "%'189 $search_columns LIKE '%" . \$db->escapeString(\$qry_words[\$i]) . "%' 190 190 ) 191 191 "; -
branches/2.0singleton/bin/module_maker/validation.cli.php
r127 r130 17 17 18 18 // Get DB tables. 19 $qid = DB::query("SHOW TABLES");19 $qid = $db->query("SHOW TABLES"); 20 20 while (list($row) = mysql_fetch_row($qid)) { 21 21 $tables[] = $row; … … 28 28 29 29 // Get DB table column info. 30 $qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));30 $qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl)); 31 31 while ($row = mysql_fetch_row($qid)) { 32 32 $cols[] = $row;
Note: See TracChangeset
for help on using the changeset viewer.