TODO: Change 'where' to array-type
509309
function store($table, $where, $fields, $append=false)
	{
		if(!$append)
			$n = $this->get("SELECT COUNT(*) FROM `".addslashes($table)."` WHERE $where");

		if(!$append && $n>0)
			$res = $this->query("UPDATE `".addslashes($table)."` ".$this->make_string_set($fields)." WHERE $where");
		else
			$res = $this->query("REPLACE INTO `".addslashes($table)."` ".$this->make_string_values($fields));

		if($res === false)
			throw new Exception("Invalid query: " . mysql_error($this->dbh) ." ");
	}
133288
function filterYMDDay(arr, disabledDateObj) {
  const newArr = [];
  const parseYMDValue = (value) => {
    const date = [];
    date[0] = (`${value}`).substring(0, 4);
    date[1] = (`${value}`).substring(4, 6) - 1;
    date[2] = (`${value}`).substring(6, 8);
    return new Date(...date).getTime();
  };
  const minDate = parseYMDValue(arr[0].value);
  const maxDate = parseYMDValue(arr[arr.length - 1].value);
  const dayRangeArr = getDateRangeArr(parseDisabledArr(disabledDateObj), minDate, maxDate);
  arr.forEach((item) => {
    const value = parseYMDValue(item.value);
    let shouldPass = true;
    for (let i = 0; i < dayRangeArr.length; i++) {
      const dis = dayRangeArr[i];
      const { start, end } = dis;
      if (value >= new Date(start).getTime() && value <= new Date(end).getTime()) {
        shouldPass = false;
        break;
      }
    }
    if (shouldPass) {
      newArr.push(item);
    }
  });
  return newArr;
}
1280499
function (query, array, exact) {
        if (!_.isArray(array) || array.length === 0) {
          return false;
        }
        return array.some(function (string) {
          if (exact) {
            return query.toLowerCase() === string.toLowerCase();
          }
          return string.toLowerCase().indexOf(query.toLowerCase()) !== -1;
        });
      }
783148
function parse_where_type_condition_array(query, type) {
	var predicates = ARRAY(type).map(function(t) {
		if(is.string(t)) {
			return new Predicate("type = $", t);
		}
		if(type instanceof NoPg.Type) {
			return new Predicate("types_id = $", type.$id);
		}
		throw new TypeError("Unknown type: " + util.inspect(t));
	}).valueOf();
	query.where( Predicate.join(predicates, 'OR') );
}
1219970
function search(user, pass, userArray) {
      return _.findWhere(userArray, { user: user, pass: pass });
    }
400682
def es_query_proto(path, selects, wheres, schema):
    
    output = None
    last_where = MATCH_ALL
    for p in reversed(sorted( wheres.keys() | set(selects.keys()))):
        where = wheres.get(p)
        select = selects.get(p)

        if where:
            where = AndOp(where).partial_eval().to_esfilter(schema)
            if output:
                where = es_or([es_and([output, where]), where])
        else:
            if output:
                if last_where is MATCH_ALL:
                    where = es_or([output, MATCH_ALL])
                else:
                    where = output
            else:
                where = MATCH_ALL

        if p == ".":
            output = set_default(
                {
                    "from": 0,
                    "size": 0,
                    "sort": [],
                    "query": where
                },
                select.to_es()
            )
        else:
            output = {"nested": {
                "path": p,
                "inner_hits": set_default({"size": 100000}, select.to_es()) if select else None,
                "query": where
            }}

        last_where = where
    return output
73933
function(where, name) {
		var orig = [][name];
		DefineList.prototype[name] = function() {
			if (!this._length) {
				// For shift and pop, we just return undefined without
				// triggering events.
				return undefined;
			}

			var args = getArgs(arguments),
				len = where && this._length ? this._length - 1 : 0,
				oldLength = this._length ? this._length : 0,
				res;

			// Call the original method.
			runningNative = true;
			res = orig.apply(this, args);
			runningNative = false;

			// Create a change where the args are
			// `len` - Where these items were removed.
			// `remove` - Items removed.
			// `undefined` - The new values (there are none).
			// `res` - The old, removed values (should these be unbound).
			queues.batch.start();
			this._triggerChange("" + len, "remove", undefined, [ res ]);
			this.dispatch('length', [ this._length, oldLength ]);
			queues.batch.stop();

			return res;
		};
	}
1068707
def where(input, property, target_value = nil)
      ary = InputIterator.new(input)

      if ary.empty?
        []
      elsif ary.first.respond_to?(:[]) && target_value.nil?
        begin
          ary.select { |item| item[property] }
        rescue TypeError
          raise_property_error(property)
        end
      elsif ary.first.respond_to?(:[])
        begin
          ary.select { |item| item[property] == target_value }
        rescue TypeError
          raise_property_error(property)
        end
      end
    end
339881
function buildWhere($where, $operand = "AND")
    {
        if (empty($where)) {
            return "";
        }

        if (is_array($where)) {
            $wheres = array();
            foreach ($where as $k => $w) {
                $wheres[] = "(" . $w . ")";
            }
            $where = implode(" $operand ", $wheres);
        }

        return " WHERE " . $where;
    }
1247602
protected function compileWheres()
	{
		if (!$this->wheres) return array();

		// The new list of compiled wheres
		$wheres = array();

		foreach ($this->wheres as $i => &$where)
		{
			// Convert id's
			if (isset($where['column']) && $where['column'] == '_id')
			{
				// Multiple values
				if (isset($where['values']))
				{
					foreach ($where['values'] as &$value)
					{
						$value = $this->convertKey($value);
					}
				}
				// Single value
				elseif (isset($where['value']))
				{
					$where['value'] = $this->convertKey($where['value']);
				}
			}

			// Convert dates
			if (isset($where['value']) && $where['value'] instanceof DateTime)
			{
				$where['value'] = $where['value']->format(DateTime::ISO8601);
			}

			// First item of chain
			if ($i == 0 && count($this->wheres) > 1 && $where['boolean'] == 'and')
			{
				// Copy over boolean value of next item in chain
				$where['boolean'] = $this->wheres[$i+1]['boolean'];
			}

			// Delegate
			$method = "compileWhere{$where['type']}";
			$compiled = $this->{$method}($where);

			// Check for or
			if ($where['boolean'] == 'or')
			{
				$compiled = array('$or' => array($compiled));
			}

			// Merge compiled where
			$wheres = array_merge_recursive($wheres, $compiled);
		}

		return $wheres;
	}
454031
function inArray(src, find, findByKey) {
    if (src.indexOf && !findByKey) {
        return src.indexOf(find);
    } else {
        var i = 0;
        while (i < src.length) {
            if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
                return i;
            }
            i++;
        }
        return -1;
    }
}
1371264
function Count($where = null) {
		$this->LoadSchema();
		if ($this->UseCache('count')) {
			$cacheid = md5(json_encode($where));

			if ($value = $this->GetCache('count', $cacheid))
				return $value;
		}

		$this->ResetQuery(array(
			'method' => 'count',
			'table' => $this->table,
			'where' => $where,
		));

		$this->Trigger('access', $where);
		if (!$this->continue)
			return 0;

		$this->Trigger('pull', $where);
		if (!$this->continue)
			return 0;

		$this->Trigger('getall', $where);
		if (!$this->continue)
			return 0;

		$this->db->select('COUNT(*) AS count');
		$this->db->from($this->table);
		if ($where = $this->FilterFields($where, 'where'))
			$this->db->where($where);
		$row = $this->db->get()->row_array();
		if (!$this->continue)
			return 0;

		return isset($cacheid) ? $this->SetCache('count', $cacheid, $row['count']) : $row['count'];
	}
1368849
static  function find($list, $where) {
        if (is_array($where)) {
            foreach ($list as $item) {
                $is_ok = true;
                foreach ($where as $key => $value) {
                    if ($item[ $key ] != $value) {
                        $is_ok = false;
                        break;
                    }
                }
                if ($is_ok) {
                    return $item;
                }
            }
        } else {
            foreach ($list as $item) {
                if ($where($item)) {
                    return $item;
                }
            }
        }
        return null;
    }
1035196
function(where, name) {
		var orig = [][name];
		DefineList.prototype[name] = function() {
			// Get the items being added.
			var args = [],
				// Where we are going to add items.
				len = where ? this._length : 0,
				i = arguments.length,
				res, val;

			// Go through and convert anything to a `map` that needs to be converted.
			while (i--) {
				val = arguments[i];
				args[i] = this.__type(val, i);
			}

			// Call the original method.
			runningNative = true;
			res = orig.apply(this, args);
			runningNative = false;

			if (!this.comparator || args.length) {
				queues.batch.start();
				this._triggerChange("" + len, "add", args, undefined);
				this.dispatch('length', [ this._length, len ]);
				queues.batch.stop();
			}

			return res;
		};
	}
1190550
public function where($where = null)
    {
        if ($where === null) {
            return $this->where;
        }
        $this->where = $where;

        return $this->where;
    }
1346248
private function assembleWhere($where = array())
    {
        if (is_array($where)) {
            switch ($where['operator']) {
                case Operator::$equals:
                    return $this->buildEquals($where['field'], $where['value']);
                case Operator::$doesNotEqual:
                    return $this->buildDoesNotEqual($where['field'], $where['value']);
                case Operator::$greaterThanOrEqual:
                    return $this->buildGreaterThanOrEquals($where['field'], $where['value']);
                case Operator::$lessThanOrEqual:
                    return $this->buildLessThanOrEquals($where['field'], $where['value']);
                case Operator::$approximateEqual:
                    return $this->buildApproximatelyEquals($where['field'], $where['value']);
                case Operator::$startsWith:
                    return $this->buildStartsWith($where['field'], $where['value']);
                case Operator::$endsWith:
                    return $this->buildEndsWith($where['field'], $where['value']);
                case Operator::$contains:
                    return $this->buildContains($where['field'], $where['value']);
                case Operator::$wildcard:
                    return $this->buildWildcard($where['field']);
            }
        }

        return;
    }
539929
public function where() {
        $this->logic('AND');
        $args = func_get_args();
        switch (count($args)) {
        case 1:
            if (is_array($args[0])) {
                $args[0] = $this->whereArray($args[0]);
            }
            $this->build()->bindExpression('where', $args[0]);
            break;
        case 2:
            $this->build()->bindExpression('where', "{$args[0]} = ?");
            $this->build()->bindParams('where', $args[1]);
            break;
        case 3:
            $this->build()->bindExpression('where', "{$args[0]} {$args[1]} ?");
            $this->build()->bindParams('where', $args[2]);
            break;
        }

        return $this->connection;
    }