src/User.php
public function search($vals)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$this->debug->log('vals', $vals);
		$return = array();
		if ($vals) {
			$where = array();
			$where_or = array();
			if (!empty($vals['username'])) {
				$where_or[] = '`username` = '.$this->db->quoteValue($vals['username']);
				unset($vals['username']);
			}
			if (!empty($vals['email'])) {
				$where_or[] = '`email` = '.$this->db->quoteValue($vals['email']);
				unset($vals['email']);
			}
			if ($where_or) {
				$where[] = '( '.implode(' OR ', $where_or).' )';
			}
			foreach ($vals as $k => $v) {
				$col = '`'.$k.'`';
				if ($k == 'userid') {
					$col = '`user`.'.$col;
				}
				$where[] = $col.' = '.$this->db->quoteValue($v);
			}
			$where = !empty($where)
				? ' WHERE '.implode(' AND ', $where)
				: '';
			$query = 'SELECT * FROM `user`'
				.' LEFT JOIN `user_auth` USING (`userid`)'
				// .' LEFT JOIN `specialties` USING (`specialtyid`)'
				.$where;
			$return = $this->db->query($query)[0];
		}
		$this->debug->table($return, 'return');
		$this->debug->groupEnd();
		return $return;
	}
public function search($vals)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$this->debug->log('vals', $vals);
		$return = array();
		if ($vals) {
			$where = array();
			$where_or = array();
			if (!empty($vals['username'])) {
				$where_or[] = '`username` = '.$this->db->quoteValue($vals['username']);
				unset($vals['username']);
			}
			if (!empty($vals['email'])) {
				$where_or[] = '`email` = '.$this->db->quoteValue($vals['email']);
				unset($vals['email']);
			}
			if ($where_or) {
				$where[] = '( '.implode(' OR ', $where_or).' )';
			}
			foreach ($vals as $k => $v) {
				$col = '`'.$k.'`';
				if ($k == 'userid') {
					$col = '`user`.'.$col;
				}
				$where[] = $col.' = '.$this->db->quoteValue($v);
			}
			$where = !empty($where)
				? ' WHERE '.implode(' AND ', $where)
				: '';
			$query = 'SELECT * FROM `user`'
				.' LEFT JOIN `user_auth` USING (`userid`)'
				// .' LEFT JOIN `specialties` USING (`specialtyid`)'
				.$where;
			$return = $this->db->query($query)[0];
		}
		$this->debug->table($return, 'return');
		$this->debug->groupEnd();
		return $return;
	}
public function search ( $ vals ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ this -> debug -> log ( 'vals' , $ vals ) ; $ return = array ( ) ; if ( $ vals ) { $ where = array ( ) ; $ where_or = array ( ) ; if ( ! empty ( $ vals [ 'username' ] ) ) { $ where_or [ ] = '`username` = ' . $ this -> db -> quoteValue ( $ vals [ 'username' ] ) ; unset ( $ vals [ 'username' ] ) ; } if ( ! empty ( $ vals [ 'email' ] ) ) { $ where_or [ ] = '`email` = ' . $ this -> db -> quoteValue ( $ vals [ 'email' ] ) ; unset ( $ vals [ 'email' ] ) ; } if ( $ where_or ) { $ where [ ] = '( ' . implode ( ' OR ' , $ where_or ) . ' )' ; } foreach ( $ vals as $ k => $ v ) { $ col = '`' . $ k . '`' ; if ( $ k == 'userid' ) { $ col = '`user`.' . $ col ; } $ where [ ] = $ col . ' = ' . $ this -> db -> quoteValue ( $ v ) ; } $ where = ! empty ( $ where ) ? ' WHERE ' . implode ( ' AND ' , $ where ) : '' ; $ query = 'SELECT * FROM `user`' . ' LEFT JOIN `user_auth` USING (`userid`)' // .' LEFT JOIN `specialties` USING (`specialtyid`)' . $ where ; $ return = $ this -> db -> query ( $ query ) [ 0 ] ; } $ this -> debug -> table ( $ return , 'return' ) ; $ this -> debug -> groupEnd ( ) ; return $ return ; }
search for user by username, email, or userid

@param array $vals values

@return array rows
search for user by username email or userid