Share Pastebin
Guest
Public paste!

mysql LOLCODE

By: a guest | Jun 16th, 2009 | Syntax: PHP | Size: 1.18 KB | Hits: 167 | Expires: Never
Copy text to clipboard
  1. <?php
  2.  
  3. /**
  4.  * LOLCode
  5.  *
  6.  * @package LOLCode
  7.  * @author 3picM1ke
  8.  * @copyright 2009
  9.  */
  10. function DB( $sHost, $sUser, $sPass, $sDb )
  11. {
  12.        
  13.         $rConn = mysql_connect( $sHost, $sUser, $sPass ) or die( mysql_error( ) );
  14.         mysql_select_db( $sDb, $rConn ) or die( mysql_error( ) );
  15.        
  16. }
  17.  
  18. function ASK( $sQuery )
  19. {
  20.        
  21.         $aSearch = array( 'CAN I PLZ GET', 'ALL UP IN', 'OMG', 'ZORT BY', 'NO MORE THAN', 'PLZ ADD TO', 'MAKE', ' IZ ', ' N ' );
  22.         $aReplace = array( 'SELECT', 'FROM', 'WHERE', 'ORDER BY', 'LIMIT', 'INSERT INTO', 'SET', ' = ', ' AND ' );
  23.    
  24.     // Not inside single quotes (strings)
  25.     $aQuotes = explode( "'", $sQuery );
  26.    
  27.     foreach( $aQuotes as $nKey => $sQuote )
  28.     {
  29.        
  30.         if( ( $nKey % 2 ) == 0 )
  31.         {
  32.            
  33.             $aQuotes[ $nKey ] = str_replace( $aSearch, $aReplace, $sQuote );
  34.                    
  35.         }
  36.            
  37.     }
  38.        
  39.         $sQuery = implode( "'", $aQuotes );
  40.        
  41.         $rResult = mysql_query( $sQuery ) or die( mysql_error( ) );
  42.        
  43.         return $rResult;
  44.        
  45. }
  46.  
  47. function MUCH( $rResult )
  48. {
  49.        
  50.         return mysql_num_rows( $rResult );
  51.        
  52. }
  53.  
  54. function DBUCKET( $rResult )
  55. {
  56.        
  57.         return mysql_fetch_assoc( $rResult );
  58.        
  59. }
  60.  
  61. ?>