<?php

    class query extends db{
        
        static $instance , $i;
        public $batch = array();
        public $batch_name = 'default';
        
        /**
         * 
         */
        public function __construct(){
            self::$instance = $this;
            self::$i = $this;
        }
        
        /**
         * 
         */
        public function put( $value , $name , $batch_name=false ){
            
            if( is_array( $value ) )
            {
                foreach( $value AS $FieldName => $FieldValue )
                {
                    $this->batch[(!$batch_name ? $this->batch_name : $batch_name)][$FieldName] = $FieldValue;
                }
            } 
            else 
            {
                $this->batch[(!$batch_name ? $this->batch_name : $batch_name)][$name] = $value;
            }
        }
        
        /**
         * 
         */
        public function getBatch( $name = false ){
            return $this->batch[($name ? $name : $this->batch_name)];
        }
        
        /**
         * Konwertuj tablice/obiekt na ciagl where dla zapytania Sql
         * @param array $WhereArray
         * @param string $Glue
         * @return string - Default return 1;
         */
        public static function where( $WhereArray , $Glue = 'AND' ){
            
            if( count( $WhereArray ) )
            {
                foreach( $WhereArray AS $key => $value )
                {
                    $Pieces[] = "`".( $key )."`='".esc( $value )."'";
                }
                
                    return join( ( ' ' . $Glue . ' ' ) , $Pieces );
            }
            
                return 1;
            
        }

        
        /**
         * 
         */
        public function order(){
            
        }
           
    }


?>