SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     $db = new PDO($dsn, $username, $password, $options);
  2.     $db1 = new PDO($dsn, $username, $password, $options);
  3.     $db2 = new PDO($dsn, $username, $password, $options);
  4.  
  5.     $sql = "SELECT
  6.                 *
  7.             FROM joblist
  8.             WHERE customer = :customer";
  9.  
  10.     $sql_val = "SELECT customer,
  11.                         SUM(value) AS total_value
  12.                 FROM  joblist                      
  13.                 GROUP By customer";
  14.  
  15.     $sql_bal = "SELECT customer,
  16.                     SUM(balance) AS total_balance
  17.                 FROM joblist
  18.                 GROUP By customer";
  19.  
  20.    //var_dump($sql_bal);
  21.  
  22.  
  23.    $customer = $_POST['customer'];
  24.    $statement = $db->prepare($sql);
  25.    $statement->bindParam(':customer', $customer, PDO::PARAM_STR);
  26.    $statement->execute();
  27.    $result = $statement->fetchAll();
  28.  
  29.    // total SUM for value  
  30.  
  31.    $stmt = $db1->prepare($sql_val);
  32.    $stmt->execute();
  33.    $totalv = $stmt->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_ASSOC);    
  34.  
  35.    $sumv = array_sum(array_column($totalv, 'total_value'));
  36.  
  37.    var_dump($totalv);
  38.  
  39.  
  40.    // total SUM for balance
  41.  
  42.    $stmt1 = $db2->prepare($sql_bal);
  43.    $stmt1->execute();
  44.    $totalb = $stmt1->fetchAll(\PDO::FETCH_GROUP|\PDO::FETCH_ASSOC);    
  45.    $sumb = array_sum(array_column($totalb, 'total_balance'));
  46.    //var_dump($totalb);
  47.  
  48.    } catch(PDOException $error) {
  49.         echo $sql . "<br>" . $error->getMessage();
  50.        die();
  51.        }
  52.  
  53.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top