Advertisement
Guest User

entrinsic performance value of database expression

a guest
Jun 5th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1. this works ---->>>
  2.  
  3.         function good_query($string, $debug=0)
  4.         {
  5.                mysql_connect("127.0.0.1", "root", "thanksrob") or die(mysql_error());
  6.         mysql_select_db("oxwall2") or die(mysql_error());
  7.         if ($debug == 1)
  8.         print $string;
  9.         if ($debug == 2)
  10.         error_log($string);
  11.         $result = mysql_query($string);
  12.         if ($result == false)
  13.         {
  14.         error_log("SQL error: ".mysql_error()."\n\nOriginal query: $string\n");
  15.         // Remove following line from production servers
  16.         die("SQL error: ".mysql_error()."\b<br>\n<br>Original query: $string \n<br>\n        <br>");
  17.         }
  18.         return $result;
  19.         }
  20.                 function good_query_table($sql, $debug=0)
  21.         {
  22.          // this function require presence of good_query() function
  23.          $result = good_query($sql, $debug);
  24.  
  25.          $table = array();
  26.          if (mysql_num_rows($result) > 0)
  27.          {
  28.          $i = 0;
  29.          while($table[$i] = mysql_fetch_assoc($result))
  30.             $i++;
  31.          unset($table[$i]);
  32.          }
  33.          mysql_free_result($result);
  34.          return $table;
  35.         }
  36.  
  37. this also works -------->>>
  38. $hostDb='mysql:host=127.0.0.1;port=3306;dbname=oxwall2';
  39.                  $user='root';
  40.                  $password='thanksrob';
  41.  
  42. $ZTH = $DBH -> prepare( "INSERT INTO bot SET id=:id, bot=:bot, username=:user, port=:port, pass=:botpass ON DUPLICATE KEY UPDATE id=:id, bot=:bot, username=:user, port=:port, pass=:botpass");
  43.          $what = OW::getUser()->getUserObject()->getUsername();
  44.                  $bot = "bnc";
  45.                  $ZTH->bindParam(':id', $num, PDO::PARAM_STR);
  46.                  $ZTH->bindParam(':bot', $bot, PDO::PARAM_STR);
  47.                  $ZTH->bindParam(':user', $what, PDO::PARAM_STR);
  48.                  $ZTH->bindParam(':port', $port, PDO::PARAM_STR);
  49.                  $ZTH->bindParam(':botpass', $pass, PDO::PARAM_STR);
  50.                  $ZTH->bindParam(':parameter', $what, PDO::PARAM_STR);
  51.          $ZTH -> execute();
  52.          $result = $ZTH -> fetch();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement