예제 #1
0
        public JoinClause on(object first, string operator1 = null, object second = null, string boolean = "and", bool where = false)
        {
            if (where)
            {
                this._bindings = ArrayUtil.push(this._bindings, second);
            }

            if (where && (operator1 == "in" || operator1 == "not in") && (second is IList <object> || second is object[]))
            {
                second = ((IList <object>)second).Count;
            }

            JoinClauseOptions options = new JoinClauseOptions();

            options.first     = first;
            options.operator1 = operator1;
            options.second    = second;
            options.boolean   = boolean;
            options.where     = where;
            options.nested    = false;

            this._clauses = ArrayUtil.push(this._clauses, options);

            return(this);
        }
예제 #2
0
        /**
         * Add a nested where statement to the query.
         *
         * @param  \Closure  $callback
         * @param  string   $boolean
         * @return \Illuminate\Database\Query\JoinClause
         */
        public JoinClause nest(Action <JoinClause> callback, string boolean = "and")
        {
            JoinClause join = new JoinClause(this._type, this._table);

            callback(join);

            if (join._clauses.Length > 0)
            {
                JoinClauseOptions options = new JoinClauseOptions();
                options.nested  = true;
                options.join    = join;
                options.boolean = boolean;

                this._clauses  = ArrayUtil.push(this._clauses, options);
                this._bindings = ArrayUtil.concat(this._bindings, join._bindings);
            }

            return(this);
        }