<commit_before><commit_msg>class order added not finished<commit_after><?php
class order
{
    private $idorder;
    private $date;
    private $iduser;
    private $isdeleted;
    private $products=[];
    //=======================================================================================================
    function __get($attr){
        return $this->$attr;
    }
    function __set($attr,$value){
        $this->$attr = $value; //variable variable
    }
    public static function createobj($iduser,$products){
        $obj = new self();
        $obj->idorder=null;
        // $obj->date=date('Y-m-d H:i:s');
        $obj->iduser=$idusr;
        $obj->products=$products;
        $obj->isdeleted=0;
        return $obj;
    }
    static function selectAll() {
        require 'config.php';
        $stmt = $mysqli->prepare("SELECT * FROM `E-Commerce`.order WHERE isdeleted = 0");
        $stmt->execute();
        $result = $stmt->get_result();
        while($obj = $result->fetch_object('order')) {
            $orders[]=$obj;
        }
        return $orders;
    }
    static function selectbyid($idorder) {
        require 'config.php';
        $stmt = $mysqli->prepare("SELECT * FROM `E-Commerce`.order
            WHERE `idorder` = ? AND isdeleted = 0");
        $stmt->bind_param('i', $idorder);
        $stmt->execute();
        $result = $stmt->get_result();
        return $result->fetch_object('order');
    }
    function insert() {
        require 'config.php';
        $stmt = $mysqli->prepare("INSERT INTO `E-Commerce`.`order`
        VALUES(null,null,?,null)");
        $stmt->bind_param('i',$this->iduser);
        return $stmt->execute();
    }
    function addProducts(){
        require 'config.php';
        $stmt = $mysqli->prepare("INSERT INTO `E-Commerce`.`orderproduct`
        VALUES(?,?,?,?)");
        foreach ($products as $value) {
            $stmt->bind_param('iidi',$this->idorder,$value->idproduct,
                $value->price,$value->orderQuantity);
            $stmt->execute();
        }
    }
    //Still working on
    function getProducts(){
        require 'config.php';
        $stmt = $mysqli->prepare("SELECT * FROM `E-Commerce`.orderproduct WHERE idorder = $this->idorder");
        $stmt->execute();
        $result = $stmt->get_result();
        while($obj = $result->fetch_obj()) {
            $products[]=$obj;
        }
        return $products;
    }
}

 ?>
{'fraction_non_alphanumeric': 0.20891824938067713, 'fraction_numerical': 0.0012386457473162675, 'mean_word_length': 2.3935574229691876, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4080491', 'n_tokens_mistral': 717, 'n_tokens_neox': 707, 'n_words': 133}