Guest User

Untitled

a guest
Jan 7th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. public function Update($table, $object, $where)
  2.     {
  3.         $sets = array();
  4.    
  5.         foreach ($object as $key => $value)
  6.         {
  7.             $key = mysql_real_escape_string($key . '');
  8.            
  9.             if ($value === null)
  10.             {
  11.                 $sets[] = "$key=NULL";         
  12.             }
  13.             else
  14.             {
  15.                 $value = mysql_real_escape_string($value . '');                
  16.                 $sets[] = " $key = $value ";
  17.             }          
  18.         }
  19.        
  20.         $sets_s = implode(',', $sets);         
  21.         $query = "UPDATE $table SET $sets_s WHERE $where";
  22.         $result = mysql_query($query);
  23.        
  24.         if (!$result)
  25.             die(mysql_error());
  26.  
  27.         return mysql_affected_rows();  
  28.     }
  29.  
  30.     public function createComment($content, $id)
  31.     {
  32.         if($content == '')
  33.             return false;
  34.         date_default_timezone_set('Europe/Kiev');
  35.         $msql = M_MSQL::Instance();
  36.         $obj = array('comment_content'=>$content, 'id_theme'=>$id);
  37.         $msql->Insert('comment', $obj);
  38.         $obj = array('dt_of_last_comment'=>date('D j M, Y H:i:s'),'how_many_comments'=>" how_many_comments + 1");
  39.         $where = "theme_id={$id}";
  40.         $msql->Update('theme', $obj, $where);
  41.  
  42.         return true;
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment