News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1284084983:v:use_geshi-1:v:type-php

Started by SleePy, Sep 10, 2010, 02:16 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

SleePy

function getTypeInfo($id_type)
{
   $request = smcFunc::db_query('', '
      SELECT name
      FROM {raw:download_prefix}types
      WHERE id_type = {int:id_type}',
      array(
         'download_prefix' => smcFunc::dbPrefix('downloads'),
         'id_type' => $id_type,
      ), smcFunc::dbConnection('downloads')
   );
   if (smcFunc::db_num_rows($request) === 0)
      fatal_error('Branch not found.');

   $row = smcFunc::db_fetch_assoc($request);
   smcFunc::db_free_result($request);
   
   return array(
      'name' => $row['name'],
   );
}

function editType($id_type, $typeData)
{
   smcFunc::db_query('', '
      UPDATE {raw:download_prefix}types
      SET
         name = {string:name},
      WHERE id_type = {int:id_type}',
      array(
         'download_prefix' => smcFunc::dbPrefix('downloads'),
         'name' => $branchData['name'],
      ), smcFunc::dbConnection('downloads', true)
   );
}

function addType($typeData)
{
   smcFunc::db_insert('',
      smcFunc::dbPrefix('downloads') . 'types',
      array(
         'name' => 'string-255',
      ),
      array(
         $branchData['name'],
      ),
      array('id_type'),
      false,
      smcFunc::dbConnection('downloads', true)
   );

   $id_branch = smcFunc::db_insert_id($download_prefix . 'branches', 'id_branch');

   return $id_branch;
}

// Get all of our types.
function getIdTypeList()
{
   $request = smcFunc::db_query('', '
      SELECT id_type, name
      FROM {raw:download_prefix}types',
      array(
         'download_prefix' => smcFunc::dbPrefix('downloads'),
      ), smcFunc::dbConnection('downloads')
   );

   $types = array();
   while ($row = smcFunc::db_fetch_assoc($request))
      $types[$row['id_type']] = $row['name'];
   smcFunc::db_free_result($request);

   return $types;
}

function getTypeValues($id_type)
{
   if (in_array($id_type, array(0,1,2,3,5,7,8,10)))
      return array('0' => 'No Options available');

   // The conversion list.
   $type_table = getIdTypeTable();

   $request = smcFunc::db_query('', '
      SELECT {raw:id_row_name}, name
      FROM {raw:download_prefix}section_{raw:table_name}',
      array(
         'download_prefix' => smcFunc::dbPrefix('downloads'),
         'id_row_name' => $type_table[$id_type][1],
         'table_name' => $type_table[$id_type][0],
      ), smcFunc::dbConnection('downloads')
   );

   $types = array();
   while ($row = smcFunc::db_fetch_assoc($request))
      $types[$row[$type_table[$id_type][1]]] = $row['name'];
   smcFunc::db_free_result($request);

   return $types;
}

function getIdTypeTable()
{
   $type_table = array(
      4 => array('languages', 'id_language'),
      6 => array('converters', 'id_converter'),
      9 => array('bridges', 'id_bridge')
   );

   return $type_table;
}
No siggy! :D