1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
-
- namespace Shop\DB;
-
- use Shop\DB\DB;
- use Psr\Container\ContainerInterface;
- use Shop\Model\CustomerOrder;
-
- class CustomerOrderDB extends DB {
-
- protected $container;
- protected $customerOrder = [];
- protected $customerName = [];
-
- public function __construct(ContainerInterface $container)
- {
- $this->container = $container;
-
- }
- public function customerOrders($args)
- {
-
- $stmt = $this->container->get('db')->prepare
- ("SELECT firstname,lastname, o.* FROM orders o
- LEFT JOIN clients c on o.customer_id = c.id
- WHERE o.customer_id =". $args['client']);
-
- $stmt ->bindValue(':id',SQLITE3_NUM);
- $stmt ->bindValue(':customer',SQLITE3_TEXT);
-
- $stmt ->bindValue(':reference', SQLITE3_TEXT);
- $stmt ->bindValue(':customer_id', SQLITE3_INTEGER);
- $stmt ->bindValue(':subtotal', SQLITE3_NUM);
- $stmt ->bindValue(':vat', SQLITE3_NUM);
- $stmt ->bindValue(':total', SQLITE3_NUM);
-
-
- $res = $stmt->execute();
-
- while($result = $res->fetchArray(SQLITE3_ASSOC)){
- $customerOrder = new CustomerOrder($this->container);
- $customerOrder->setId($result['id']);
- $customerOrder->setRef($result['reference']);
- $customerOrder->setCustomerId($result['customer_id']);
- $customerOrder->setSubtotal($result['subtotal']);
- $customerOrder->setVat($result['vat']);
- $customerOrder->setTotal($result['total']);
- $this->customerOrders[] = $customerOrder;
- }
- return $this->customerOrders;
- }
- public function nameCustomer($args){
- $stmt2 = $this->container->get('db')->prepare("SELECT * FROM clients WHERE id = " . $args['client']);
- $stmt2 ->bindValue(':firstname', SQLITE3_TEXT);
- $stmt2 ->bindValue(':lastname', SQLITE3_TEXT);
- $res2 = $stmt2->execute();
- while($result = $res2->fetchArray(SQLITE3_ASSOC));{
- $customerName = new CustomerOrder($this->container);
- $customerName->setFirstname($result['firstname']);
- $customerName->setLastname($result['lastname']);
- $this->customersName[] = $customerName;
- }
- }
- }
-
-
-
- //vergeet args niet zie index route order/id , gebruik psr container; done
|