<commit_before><?php
/*
 *  Copyright (c) 2012-2015  <NAME> <<EMAIL>>,
 *                           <NAME> <<EMAIL>>,
 *                           AIP E-Science (www.aip.de)
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class Auth_Model_Resource_User extends Daiquiri_Model_Resource_Table {

    /**
     * Constructor. Sets tablename.
     */
    public function __construct() {
        $this->setTablename('Auth_User');
    }

    /**
     * Returns the colums of the joined user table.
     * @return array $cols
     */
    public function fetchCols() {
        $cols = parent::fetchCols();
        $cols['role'] = $this->quoteIdentifier('Auth_Roles','role');
        $cols['status'] = $this->quoteIdentifier('Auth_Status','status');
        return $cols;
    }

    /**
     * Fetches a set of rows from the (joined) Auth tables specified by $sqloptions.
     * @param array $sqloptions array of sqloptions (start,limit,order,where)
     * @return array $rows
     */
    public function fetchRows(array $sqloptions = array()) {
        $select = $this->select($sqloptions);
        $select->from('Auth_User', array('id','username','email','role_id','status_id'));
        $select->join('Auth_Roles', 'Auth_Roles.id = Auth_User.role_id', array('role'));
        $select->join('Auth_Status', 'Auth_Status.id = Auth_User.status_id', array('status'));

        // get the rowset and return
        return $this->fetchAll($select);
    }

    /**
     * Counts the number of rows in the (joined) Auth tables.
     * @param @param array $sqloptions array of sqloptions (start,limit,order,where,from)
     * @return int $count
     */
    public function countRows(array $sqloptions = array()) {
        $select = $this->select();
        $select->from('Auth_User', 'COUNT(*) as count');
        $select->join('Auth_Roles', 'Auth_Roles.id = Auth_User.role_id', array('role'));
        $select->join('Auth_Status', 'Auth_Status.id = Auth_User.status_id', array('status'));

        if ($sqloptions) {
            $select->setWhere($sqloptions);
            $select->setOrWhere($sqloptions);
        }

        // query database and return
        $row = $this->fetchOne($select);
        return (int) $row['count'];
    }

    /**
     * Fetches a specific row from the (joined) Auth tables.
     * @param mixed $input primary key of the row OR array of sqloptions (start,limit,order,where)
     * @throws Exception
     * @return array $row
     */
    public function fetchRow($input) {
        if (empty($input)) {
            throw new Exception('$id or $sqloptions not provided in ' . get_class($this) . '::' . __FUNCTION__ . '()');
        }
        if (is_array($input)) {
            $select = $this->select($input);
        } else {
            $select = $this->select();
            $select->where('Auth_User.id = ?', $input);
        }

        $select->from('Auth_User', array('id','username','email','role_id','status_id'));<commit_msg>fix for "Mixing of GROUP columns" bug<commit_after><?php
/*
 *  Copyright (c) 2012-2015  <NAME> <<EMAIL>>,
 *                           <NAME> <<EMAIL>>,
 *                           AIP E-Science (www.aip.de)
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class Auth_Model_Resource_User extends Daiquiri_Model_Resource_Table {

    /**
     * Constructor. Sets tablename.
     */
    public function __construct() {
        $this->setTablename('Auth_User');
    }

    /**
     * Returns the colums of the joined user table.
     * @return array $cols
     */
    public function fetchCols() {
        $cols = parent::fetchCols();
        $cols['role'] = $this->quoteIdentifier('Auth_Roles','role');
        $cols['status'] = $this->quoteIdentifier('Auth_Status','status');
        return $cols;
    }

    /**
     * Fetches a set of rows from the (joined) Auth tables specified by $sqloptions.
     * @param array $sqloptions array of sqloptions (start,limit,order,where)
     * @return array $rows
     */
    public function fetchRows(array $sqloptions = array()) {
        $select = $this->select($sqloptions);
        $select->from('Auth_User', array('id','username','email','role_id','status_id'));
        $select->join('Auth_Roles', 'Auth_Roles.id = Auth_User.role_id', array('role'));
        $select->join('Auth_Status', 'Auth_Status.id = Auth_User.status_id', array('status'));

        // get the rowset and return
        return $this->fetchAll($select);
    }

    /**
     * Counts the number of rows in the (joined) Auth tables.
     * @param @param array $sqloptions array of sqloptions (start,limit,order,where,from)
     * @return int $count
     */
    public function countRows(array $sqloptions = array()) {
        $select = $this->select();
        $select->from('Auth_User', 'COUNT(*) as count');
        $select->join('Auth_Roles', 'Auth_Roles.id = Auth_User.role_id', false);
        $select->join('Auth_Status', 'Auth_Status.id = Auth_User.status_id', false);

        if ($sqloptions) {
            $select->setWhere($sqloptions);
            $select->setOrWhere($sqloptions);
        }

        // query database and return
        $row = $this->fetchOne($select);
        return (int) $row['count'];
    }

    /**
     * Fetches a specific row from the (joined) Auth tables.
     * @param mixed $input primary key of the row OR array of sqloptions (start,limit,order,where)
     * @throws Exception
     * @return array $row
     */
    public function fetchRow($input) {
        if (empty($input)) {
            throw new Exception('$id or $sqloptions not provided in ' . get_class($this) . '::' . __FUNCTION__ . '()');
        }
        if (is_array($input)) {
            $select = $this->select($input);
        } else {
            $select = $this->select();
            $select->where('Auth_User.id = ?', $input);
        }

        $select->from('Auth_User', array('id','username','email','role_id','status_id'));
{'fraction_non_alphanumeric': 0.13987183059348007, 'fraction_numerical': 0.0025076623014767345, 'mean_word_length': 2.6834273986659825, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1350955', 'n_tokens_mistral': 2104, 'n_tokens_neox': 2063, 'n_words': 603}