<commit_before><?php
/**
 * Belgian Police Web Platform - Police Component
 *
 * @copyright	Copyright (C) 2012 - 2013 Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		https://github.com/belgianpolice/internet-platform
 */

namespace Nooku\Component\Streets;
use Nooku\Library;

class ModelMunicipalities extends Library\ModelTable
{
	public function __construct(Library\ObjectConfig $config)
	{
		parent::__construct($config);

		$this->getState()
		    ->insert('zone' , 'int')
			->insert('municipality', 'string')
			->insert('language', 'string')
            ->insert('parent_id' , 'int');
	}

    protected function _buildQueryColumns(Library\DatabaseQuerySelect $query)
	{
		parent::_buildQueryColumns($query);

		$query->columns(array(
			'city_title'  => 'city.title',
			'police_zone_id'  => 'city.police_zone_id'
		));
	}

	protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
	{
        $query->join(array('city' => 'data.streets_cities'), 'city.streets_city_id = tbl.streets_city_id');
	}

    protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
	{
		parent::_buildQueryWhere($query);
		$state = $this->getState();

		if (!is_numeric($state->search)) {
			$query->where('tbl.title LIKE :search')->bind(array('search' => '%'.$state->search.'%'));
		} else {
			$query->where('tbl.postcode = :search')->bind(array('search' => $state->search));
		}
<commit_msg>#19 - Add parent city to title<commit_after><?php
/**
 * Belgian Police Web Platform - Police Component
 *
 * @copyright	Copyright (C) 2012 - 2013 Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		https://github.com/belgianpolice/internet-platform
 */

namespace Nooku\Component\Streets;
use Nooku\Library;

class ModelMunicipalities extends Library\ModelTable
{
	public function __construct(Library\ObjectConfig $config)
	{
		parent::__construct($config);

		$this->getState()
		    ->insert('zone' , 'int')
			->insert('municipality', 'string')
			->insert('language', 'string')
            ->insert('parent_id' , 'int');
	}

    protected function _buildQueryColumns(Library\DatabaseQuerySelect $query)
	{
		parent::_buildQueryColumns($query);

		$query->columns(array(
			'city_title'  => 'city.title',
			'police_zone_id'  => 'city.police_zone_id',
			'title' => "IF(tbl.parent_id, CONCAT(tbl.title,' (',parent.title,')'), tbl.title)"
		));
	}

	protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
	{
        $query->join(array('city' => 'data.streets_cities'), 'city.streets_city_id = tbl.streets_city_id')
			  ->join(array('parent' => 'data.streets_municipalities'), 'parent.streets_municipality_id = tbl.parent_id');
	}

    protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
	{
		parent::_buildQueryWhere($query);
		$state = $this->getState();

		if (!is_numeric($state->search)) {
			$query->where('tbl.title LIKE :search')->bind(array('search' => '%'.$state->search.'%'));
		} else {
			$query->where('tbl.postcode = :search')->bind(array('search' => $state->search));
		}

{'fraction_non_alphanumeric': 0.17723525681674066, 'fraction_numerical': 0.0063411540900443885, 'mean_word_length': 4.6138790035587185, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 48, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '1776956', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1041, 'n_words': 170}