public function where( $column, $param1 = null, $param2 = null, $type = 'and' ) {

		// Check if the where type is valid.
		if ( ! in_array( $type, array( 'and', 'or', 'where' ) ) ) {
			throw new \Exception( 'Invalid where type "' . $type . '"' );
		}

		$sub_type = is_null( $param1 ) ? $type : $param1;
		if ( empty( $this->statements['wheres'] ) ) {
			$type = 'where';
		}

		// When column is an array we assume to make a bulk and where.
		if ( is_array( $column ) ) {
			$subquery = array();
			foreach ( $column as $value ) {
				if ( ! isset( $value[2] ) ) {
					$value[2] = $value[1];
					$value[1] = '=';
				}
				$subquery[] = $this->generateWhere( $value[0], $value[1], $value[2], empty( $subquery ) ? '' : $sub_type );
			}

			$this->statements['wheres'][] = $type . ' ( ' . trim( join( ' ', $subquery ) ) . ' )';

			return $this;
		}

		$this->statements['wheres'][] = $this->generateWhere( $column, $param1, $param2, $type );

		return $this;
	}
public function where( $column, $param1 = null, $param2 = null, $type = 'and' ) {

		// Check if the where type is valid.
		if ( ! in_array( $type, array( 'and', 'or', 'where' ) ) ) {
			throw new \Exception( 'Invalid where type "' . $type . '"' );
		}

		$sub_type = is_null( $param1 ) ? $type : $param1;
		if ( empty( $this->statements['wheres'] ) ) {
			$type = 'where';
		}

		// When column is an array we assume to make a bulk and where.
		if ( is_array( $column ) ) {
			$subquery = array();
			foreach ( $column as $value ) {
				if ( ! isset( $value[2] ) ) {
					$value[2] = $value[1];
					$value[1] = '=';
				}
				$subquery[] = $this->generateWhere( $value[0], $value[1], $value[2], empty( $subquery ) ? '' : $sub_type );
			}

			$this->statements['wheres'][] = $type . ' ( ' . trim( join( ' ', $subquery ) ) . ' )';

			return $this;
		}

		$this->statements['wheres'][] = $this->generateWhere( $column, $param1, $param2, $type );

		return $this;
	}
public function where ( $ column , $ param1 = null , $ param2 = null , $ type = 'and' ) { // Check if the where type is valid. if ( ! in_array ( $ type , array ( 'and' , 'or' , 'where' ) ) ) { throw new \ Exception ( 'Invalid where type "' . $ type . '"' ) ; } $ sub_type = is_null ( $ param1 ) ? $ type : $ param1 ; if ( empty ( $ this -> statements [ 'wheres' ] ) ) { $ type = 'where' ; } // When column is an array we assume to make a bulk and where. if ( is_array ( $ column ) ) { $ subquery = array ( ) ; foreach ( $ column as $ value ) { if ( ! isset ( $ value [ 2 ] ) ) { $ value [ 2 ] = $ value [ 1 ] ; $ value [ 1 ] = '=' ; } $ subquery [ ] = $ this -> generateWhere ( $ value [ 0 ] , $ value [ 1 ] , $ value [ 2 ] , empty ( $ subquery ) ? '' : $ sub_type ) ; } $ this -> statements [ 'wheres' ] [ ] = $ type . ' ( ' . trim ( join ( ' ' , $ subquery ) ) . ' )' ; return $ this ; } $ this -> statements [ 'wheres' ] [ ] = $ this -> generateWhere ( $ column , $ param1 , $ param2 , $ type ) ; return $ this ; }
Create a where statement

->where('name', 'ladina')
->where('age', '>', 18)
->where('name', 'in', ['charles', 'john', 'jeffry'])

@throws \Exception If $type is not 'and', 'or', 'where'.

@param mixed  $column The SQL column.
@param mixed  $param1 Operator or value depending if $param2 isset.
@param mixed  $param2 The value if $param1 is an operator.
@param string $type the where type ( and, or ).

@return self The current query builder.
Create a where statement