<commit_before><?php
namespace Atlas\Database;

class Factory
{
    protected $_config;

    public function __construct($config)
    {
        $this->_config = $config;
    }

    public function adapter($mode)
    {
        if (empty($mode)) {
            throw new Exception("Db adapter mode not specified");
        }

        if (!in_array($mode, array('write','read'))) {
            throw new Exception("Invalid db adapter mode '{$mode}' specified");
        }

        if (!array_key_exists($mode, $this->_config)) {
            throw new Exception("Malformed db adapter {$mode} config specified");
        }

        return new \Zend_Db_Adapter_Pdo_Mysql(
            $this->_config[$mode]
        );
    }

    public function select($resolver, $ignoreEmptyValues = false)
    {
        return new Select(
            new \Zend_Db_Select($this->adapter('read')),
            $resolver->mapper()->getAlias(), 
            $ignoreEmptyValues
        );
    }

    public function fetch($resolver, $key)
    {
        $mapper = $resolver->mapper();
        $select = $this->select($resolver, $mapper->getAlias())
            ->isEqual('id', $key);

        return new Fetch(
            $this->adapter('read'), $mapper, $select
        );
    }

    public function relation($resolver, $entity)
    {
        if (is_numeric($entity)) {
            $entity = $this->fetch($key);
        }

        return $resolver->relation($this, $entity);
    }

    public function named($resolver)
    {
        return $resolver->named($this);
    }
    
    public function query($resolver, $ignoreEmptyValues = false)
    {
        return $resolver->query(
            $this->adapter('read'), 
            $resolver->mapper(), 
            $this->select($ignoreEmptyValues)
        );
    }

    public function write($resolver)
    {
        return new Write(
            $this->adapter('write'), $resolver->mapper() 
        );
    }
}<commit_msg>Fixed another internal call to select()<commit_after><?php
namespace Atlas\Database;

class Factory
{
    protected $_config;

    public function __construct($config)
    {
        $this->_config = $config;
    }

    public function adapter($mode)
    {
        if (empty($mode)) {
            throw new Exception("Db adapter mode not specified");
        }

        if (!in_array($mode, array('write','read'))) {
            throw new Exception("Invalid db adapter mode '{$mode}' specified");
        }

        if (!array_key_exists($mode, $this->_config)) {
            throw new Exception("Malformed db adapter {$mode} config specified");
        }

        return new \Zend_Db_Adapter_Pdo_Mysql(
            $this->_config[$mode]
        );
    }

    public function select($resolver, $ignoreEmptyValues = false)
    {
        return new Select(
            new \Zend_Db_Select($this->adapter('read')),
            $resolver->mapper()->getAlias(), 
            $ignoreEmptyValues
        );
    }

    public function fetch($resolver, $key)
    {
        $mapper = $resolver->mapper();
        $select = $this->select($resolver, $mapper->getAlias())
            ->isEqual('id', $key);

        return new Fetch(
            $this->adapter('read'), $mapper, $select
        );
    }

    public function relation($resolver, $entity)
    {
        if (is_numeric($entity)) {
            $entity = $this->fetch($key);
        }

        return $resolver->relation($this, $entity);
    }

    public function named($resolver)
    {
        return $resolver->named($this);
    }
    
    public function query($resolver, $ignoreEmptyValues = false)
    {
        return $resolver->query(
            $this->adapter('read'), 
            $resolver->mapper(), 
            $this->select($resolver, $ignoreEmptyValues)
        );
    }

    public function write($resolver)
    {
        return new Write(
            $this->adapter('write'), $resolver->mapper() 
        );
    }
}
{'fraction_non_alphanumeric': 0.1431117901706137, 'fraction_numerical': 0.0, 'mean_word_length': 2.0238645111624325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '1759471', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1091, 'n_words': 232}