Example #1
0
    public function SelectCustomerAll()
    {
        $sql = "SELECT * FROM customer";
        $res = parent::executeSQL($sql, null);
        $data = "<table class='recordlist'>";
        $data .= "<tr><th>ID</th><th>顧客名</th><th>TEL</th><th>Email</th><th></th><th></th></tr>\n";
        foreach ($rows = $res->fetchAll(PDO::FETCH_NUM) as $row) {
            $data .= "<tr>";
            for ($i = 0; $i < count($row); $i++) {
                $data .= "<td>{$row[$i]}</td>";
            }
            // 更新ボタンのコード
            $data .= <<<eof
\t\t\t<td><form method='post' action=''>
\t\t\t<input type='hidden' name='id' value='{$row[0]}'>
\t\t\t<input type='submit' name='update' value=' 更新 '>
\t\t\t</form></td>
eof;
            //削除ボタンのコード
            $data .= <<<eof
\t\t\t<td><form method='post' action=''>
\t\t\t<input type='hidden' name='id' value='{$row[0]}'>
\t\t\t<input type='submit' name='delete' id='delete' value=' 削除 ' onClick='return CheckDelete()'>
\t\t\t</form></td>
eof;
            $data .= "</tr>\n";
        }
        $data .= "</table>\n";
        return $data;
    }
Example #2
0
 public function SelectGoodsAll()
 {
     $sql = "SELECT * FROM goods";
     $res = parent::executeSQL($sql, null);
     $records = "<table>\n";
     while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
         $records .= "<tr><td>{$row['GoodsID']}</td>";
         $records .= "<td>{$row['GoodsName']}</td>";
         $records .= "<td>{$row['Price']}</td></tr>\n";
     }
     $records .= "</table>\n";
     return $records;
 }
Example #3
0
    private function getSalesinfo($startDate, $endDate, $CustomerID)
    {
        $sql = <<<eof
    SELECT salesinfo.id,salesinfo.SalesDate,salesinfo.GoodsID,goods.GoodsName,
    goods.Price,salesinfo.Quantity,(goods.Price*salesinfo.Quantity)
    FROM salesinfo INNER JOIN goods ON salesinfo.GoodsID=goods.GoodsID
    WHERE salesinfo.SalesDate BETWEEN ? AND ?
    AND salesinfo.CustomerID=?
    ORDER BY salesinfo.SalesDate,salesinfo.id
eof;
        $array = array($startDate, $endDate, $CustomerID);
        $res = parent::executeSQL($sql, $array);
        return $res;
    }
Example #4
0
 public function DeleteGoods($GoodsID)
 {
     $sql = "DELETE FROM goods WHERE GoodsID=?";
     $array = array($GoodsID);
     parent::executeSQL($sql, $array);
 }
Example #5
0
    public function SelectSlips($salesDate)
    {
        //日付で抽出
        $sql = <<<eof
    \tSELECT distinct salesinfo.SalesDate,salesinfo.CustomerID,customer.CustomerName
    \tFROM salesinfo INNER JOIN customer ON salesinfo.CustomerID=customer.CustomerID
    \tWHERE salesinfo.SalesDate=?
    \tORDER BY customer.CustomerID
eof;
        $array = array($salesDate);
        $res = parent::executeSQL($sql, $array);
        $data = "";
        foreach ($rows = $res->fetchAll(PDO::FETCH_NUM) as $row) {
            $data .= "<tr>";
            for ($i = 0; $i < count($row); $i++) {
                $data .= "<td>{$row[$i]}</td>";
            }
            $data .= <<<eof
      \t<td><form method='post' action=''>
      \t<input type='hidden' name='SalesDate' value='{$row[0]}'>
      \t<input type='hidden' name='CustomerID' value='{$row[1]}'>
      \t<input type='submit' name='detail' value='詳細'></form></td>
      \t<td><form method='post' action=''>
      \t<input type='hidden' name='SalesDate' value='{$row[0]}'>
      \t<input type='hidden' name='CustomerID' value='{$row[1]}'>
      \t<input type='submit' name='delete' value='削除' onClick='return CheckDelete()'></form>
      \t</td></tr>

eof;
        }
        return $data;
    }
Example #6
0
<!-- 6-2 本格的なクラスを作ろう -->
<!-- DBクラスを使ってみる -->
<?php 
require_once 'db.php';
$db = new DB();
$sql = "SELECT * FROM goods";
$res = $db->executeSQL($sql, null);
$recordlist = "<table>\n";
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
    $recordlist .= "<tr><td>{$row['GoodsID']}</td>";
    $recordlist .= "<td>{$row['GoodsName']}</td>";
    $recordlist .= "<td>{$row['Price']}</td></tr>\n";
}
$recordlist .= "</table>\n";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>クラスの活用</title>
</head>
<body>
<h1>goodsマスターテーブル</h1>
<?php 
echo $recordlist;
?>
</body>
</html>
Example #7
0
<!-- 6-2 本格的なクラスを作ろう -->
<!-- 新規登録もできるようにしよう -->
<?php 
require_once 'db.php';
$db = new DB();
// 新規登録の処理
if (isset($_POST['insert'])) {
    $sql = "INSERT INTO goods VALUES(?,?,?)";
    $array = array($_POST['GoodsID'], $_POST['GoodsName'], $_POST['Price']);
    $db->executeSQL($sql, $array);
}
// 全レコードを表示する処理
$sql = "SELECT * FROM goods";
$res = $db->executeSQL($sql, null);
$recordlist = "<table>\n";
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
    $recordlist .= "<tr><td>{$row['GoodsID']}</td>";
    $recordlist .= "<td>{$row['GoodsName']}</td>";
    $recordlist .= "<td>{$row['Price']}</td></tr>\n";
}
$recordlist .= "</table>\n";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>クラスの活用</title>
</head>
<body>
<h1>goodsマスターテーブル</h1>
<form action="" method="post">