Added: Create new refuel record
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build and Deploy Zola Website / build_and_deploy (push) Successful in 13s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build and Deploy Zola Website / build_and_deploy (push) Successful in 13s
				
			This commit is contained in:
		@@ -1,5 +1,37 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class Refuel {
 | 
			
		||||
    private $db;
 | 
			
		||||
 | 
			
		||||
    public function __construct() {
 | 
			
		||||
        $this->db = Database::getInstance()->getConnection();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function create($data) {
 | 
			
		||||
        try{
 | 
			
		||||
            $stmt = $this->db->prepare("
 | 
			
		||||
                INSERT INTO refueling_records (user_id, vehicle_id, fuel_type, note, liters, price_per_liter, total_price, created_at)
 | 
			
		||||
                VALUES (?, ?, ?, ?, ?, ?, ?, NOW())
 | 
			
		||||
            ");
 | 
			
		||||
 | 
			
		||||
            $stmt->bind_param(
 | 
			
		||||
                "iissddd",
 | 
			
		||||
                $data['user_id'],
 | 
			
		||||
                $data['vehicle_id'],
 | 
			
		||||
                $data['fuel_type'],
 | 
			
		||||
                $data['note'],
 | 
			
		||||
                $data['liters'],
 | 
			
		||||
                $data['price_per_liter'],
 | 
			
		||||
                $data['total_price'],
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            if ($stmt->execute()) {
 | 
			
		||||
                return true;
 | 
			
		||||
            } else {
 | 
			
		||||
                return "Error: " . $stmt->error;
 | 
			
		||||
            }
 | 
			
		||||
        } catch(mysqli_sql_exception $e) {
 | 
			
		||||
            return $e->getMessage();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user