<commit_before><?php
namespace DAO;
use DAO;
use DAO\QueryClass as QC;

/**
 * Functional MySQL Operator
 */
class MySQLOperator {
	use DAO\Operator\Traits\Mongo;
	use DAO\Operator\Traits\XHelpers;

	/** query class */
	protected $class;
	/** main table */
	protected $from;
	/** dao */
	protected $dao;
	/** order by what */
	protected $orderby;
	/** order by desc */
	protected $orderbyDesc = false;
	/** group by */
	protected $groupby;
	/** having */
	protected $having;
	/**
	 * массив [
	 *	'table' => 'table',
	 *	'on'    => condition
	 * ]
	 */
	protected $join = [];
	/** Limitation */
	protected $limit;
	/** Skip */
	protected $skip;
	/** Fields */
	protected $fields = [];
	/** Condition */
	protected $condition = 0; // false
	/** IGNORE (в случае INSERT) */
	protected $ignore = false;
	/** установки SET (в случае UPDATE) */
	protected $set;
	/** суффикс (дополнение к запросу) -- пока для INSERT */
	protected $suffix;
	/**
	 * предикат -- для функциональных условных записей
	 *
	 * с предикатом работают только операторы join
	 * пример $obj->on($u->isAdmin())->join(...)
	 */
	protected $predicate = true;
	/**
	 * Query classes
	 */
	protected $classes_allowed =
		['select', 'update', 'delete', 'insert'];
	protected $helper = null;

	/**
	 * Create MySQLOperator object
	 *
	 * @param $class one of $this->classes_allowed
	 * @param $from operation table
	 * @param $param1 depend on class
	 *
	 * * select: $fields, $condition
	 * * update: $set, $condition
	 * * insert: $fields, $values
	 * * delete: $condition
	 *
	 * @param $param2 see param1
	 */
	public function __construct($class, $param1 = null, $param2 = null, $param3 = null) {
		if (!in_array($class, $this->classes_allowed, true))
			throw new InvalidArgumentException("incorrect class");
		$this->class = $class;
		switch ($class) {
			case QC::select:
				if ($param1)
					$this->fields = $param1;
				if ($param2)
					$this->condition = $param2;
				break;
			case QC::update:
				if ($param1)
					$this->set = $param1;
				if ($param2)
					$this->condition = $param2;
				break;
			case QC::delete:
				if ($param1)
					$this->condition = $param1;
				break;
			case QC::insert:
				if ($param1)
					$this->fields = $param1;
				if ($param2)
					$this->ignore = $param2;
				if ($param3)
					$this->suffix = $param3;
				break;
		}
	}

	protected static function quoteTableName($v) {
		return (strpos($v, ' ') !== false) ? $v : "`$v`";
	}

	/**
	 * основная таблица для изменения
	 */
	public function in($from) {
		return $this->from($from);
	}

	/**
	 * добавить поля
	 */
	public function add_fields($fields) {
		$this->fields = array_merge($this->fields, $fields);
		return $this;
	}

	/**
	 * основная таблица вставки
	 */
	public function into($from) {
		return $this->from($from);
	}

	/**
	 * основная таблица выборки
	 */
	public function from($from) {
		if (is_object($from)) {
			$this->dao = $from;
			$from = $from->getName();
		}
		$this->from = static::quoteTableName($from);
		return $this;
	}

	/**
	 * Сортировка
	 */
	public function orderBy($what, $desc = false) {
		$this->orderby = $what;
		$this->orderbyDesc = $desc;
		return $this;
	}

	public function set($set) {
		$this->set = $set;
		return $this;
	}
<commit_msg>group_by in MySQLOperator<commit_after><?php
namespace DAO;
use DAO;
use DAO\QueryClass as QC;

/**
 * Functional MySQL Operator
 */
class MySQLOperator {
	use DAO\Operator\Traits\Mongo;
	use DAO\Operator\Traits\XHelpers;

	/** query class */
	protected $class;
	/** main table */
	protected $from;
	/** dao */
	protected $dao;
	/** order by what */
	protected $orderby;
	/** order by desc */
	protected $orderbyDesc = false;
	/** group by */
	protected $groupby;
	/** having */
	protected $having;
	/**
	 * массив [
	 *	'table' => 'table',
	 *	'on'    => condition
	 * ]
	 */
	protected $join = [];
	/** Limitation */
	protected $limit;
	/** Skip */
	protected $skip;
	/** Fields */
	protected $fields = [];
	/** Condition */
	protected $condition = 0; // false
	/** IGNORE (в случае INSERT) */
	protected $ignore = false;
	/** установки SET (в случае UPDATE) */
	protected $set;
	/** суффикс (дополнение к запросу) -- пока для INSERT */
	protected $suffix;
	/**
	 * предикат -- для функциональных условных записей
	 *
	 * с предикатом работают только операторы join
	 * пример $obj->on($u->isAdmin())->join(...)
	 */
	protected $predicate = true;
	/**
	 * Query classes
	 */
	protected $classes_allowed =
		['select', 'update', 'delete', 'insert'];
	protected $helper = null;

	/**
	 * Create MySQLOperator object
	 *
	 * @param $class one of $this->classes_allowed
	 * @param $from operation table
	 * @param $param1 depend on class
	 *
	 * * select: $fields, $condition
	 * * update: $set, $condition
	 * * insert: $fields, $values
	 * * delete: $condition
	 *
	 * @param $param2 see param1
	 */
	public function __construct($class, $param1 = null, $param2 = null, $param3 = null) {
		if (!in_array($class, $this->classes_allowed, true))
			throw new InvalidArgumentException("incorrect class");
		$this->class = $class;
		switch ($class) {
			case QC::select:
				if ($param1)
					$this->fields = $param1;
				if ($param2)
					$this->condition = $param2;
				break;
			case QC::update:
				if ($param1)
					$this->set = $param1;
				if ($param2)
					$this->condition = $param2;
				break;
			case QC::delete:
				if ($param1)
					$this->condition = $param1;
				break;
			case QC::insert:
				if ($param1)
					$this->fields = $param1;
				if ($param2)
					$this->ignore = $param2;
				if ($param3)
					$this->suffix = $param3;
				break;
		}
	}

	protected static function quoteTableName($v) {
		return (strpos($v, ' ') !== false) ? $v : "`$v`";
	}

	/**
	 * основная таблица для изменения
	 */
	public function in($from) {
		return $this->from($from);
	}

	/**
	 * добавить поля
	 */
	public function add_fields($fields) {
		$this->fields = array_merge($this->fields, $fields);
		return $this;
	}

	/**
	 * основная таблица вставки
	 */
	public function into($from) {
		return $this->from($from);
	}

	/**
	 * основная таблица выборки
	 */
	public function from($from) {
		if (is_object($from)) {
			$this->dao = $from;
			$from = $from->getName();
		}
		$this->from = static::quoteTableName($from);
		return $this;
	}

	/**
	 * Сортировка
	 */
	public function orderBy($what, $desc = false) {
		$this->orderby = $what;
		$this->orderbyDesc = $desc;
		return $this;
	}

	public function set($set) {
		$this->set = $set;
		return $this;
	}

	public function group_by($groupby) {
		$this->groupby = $groupby;
		return $this;
	}

{'fraction_non_alphanumeric': 0.17428962163804892, 'fraction_numerical': 0.006989819176416958, 'mean_word_length': 3.0256880733944955, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '2949142', 'n_tokens_mistral': 2652, 'n_tokens_neox': 2364, 'n_words': 581}