Author Topic: Paste-1268761867:v:use_geshi-1:v:type-php  (Read 292 times)

0 Members and 1 Guest are viewing this topic.

Offline SleePy

  • PHP Lover
  • Administrator
  • ********
  • Posts: 346
  • Karma: +1339/-0
  • Gender: Male
  • I like Pi
    • View Profile
    • SleePy Code
Paste-1268761867:v:use_geshi-1:v:type-php
« on: March 16, 2010, 09:51:07 am »
// SleePy is lazy, so I will just check to see if db_query exists
if(!function_exists('db_query'))
{
   db_extend('Packages');
   function db_query($query, $file, $line)
   {
      global $smcFunc;
      return $smcFunc['db_query']('', $query, array('db_error_skip' => true));
   }
}
// All work here is for back support for SMF 1.1, It is easier to support 2.0 and backport.
else
{
   $smcFunc = $func;
   $smcFunc['db_num_rows'] = 'mysql_num_rows';
   $smcFunc['db_free_result'] = 'mysql_free_result';
   $smcFunc['db_fetch_assoc'] = 'mysql_fetch_assoc';
   $smcFunc['db_list_columns'] = 'mysql_show_columns';
   $smcFunc['db_add_column'] = 'mysql_create_columns';

   // Quickly emulate these functions.
   function mysql_show_columns($table_name)
   {
      global $smcFunc, $db_prefix;

      $result = db_query("SHOW FIELDS FROM {$table_name}", __FILE__, __LINE__);;
      $columns = array();
      while ($row = $smcFunc['db_fetch_assoc']($result))
         $columns[] = $row['Field'];
      return $columns;
   }
   function mysql_create_columns($table_name, $column_info)
   {
      global $db_prefix;

      return db_query('ALTER TABLE ' . $table_name . '
         ADD ' . $column_info['name'] . ' ' . $column_info['type'] . ' ' . (empty($column_info['null']) ? 'NOT NULL' : '') . ' ' .
      (empty($column_info['default']) ? '' : 'default \'' . $column_info['default'] . '\'') . ' ' .
      (empty($column_info['auto']) ? '' : 'auto_increment') . ' ', __FILE__, __LINE__);
   }
}
No siggy! :D

 

Templates: 3: index (CurveSite), Display (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 1: index+Modifications.english (CurveSite).
Style sheets: 1: site (default).
Files included: 15 - 643KB. (show)
Cache hits: 13: 0.00191s for 14,744 bytes (show)
Queries used: 22.

[Show Queries]