ezSQL_mysqli::select PHP Method

select() public method

******************************************************************** Try to select a mySQL database
public select ( $dbname = '', $encoding = '' )
    function select($dbname = '', $encoding = '')
    {
        global $ezsql_mysqli_str;
        $return_val = false;
        // Must have a database name
        if (!$dbname) {
            $this->register_error($ezsql_mysqli_str[3] . ' in ' . __FILE__ . ' on line ' . __LINE__);
            $this->show_errors ? trigger_error($ezsql_mysqli_str[3], E_USER_WARNING) : null;
        } else {
            if (!$this->dbh) {
                $this->register_error($ezsql_mysqli_str[4] . ' in ' . __FILE__ . ' on line ' . __LINE__);
                $this->show_errors ? trigger_error($ezsql_mysqli_str[4], E_USER_WARNING) : null;
            } else {
                if (!@$this->dbh->select_db($dbname)) {
                    // Try to get error supplied by mysql if not use our own
                    if (!($str = @$this->dbh->error)) {
                        $str = $ezsql_mysqli_str[5];
                    }
                    $this->register_error($str . ' in ' . __FILE__ . ' on line ' . __LINE__);
                    $this->show_errors ? trigger_error($str, E_USER_WARNING) : null;
                } else {
                    $this->dbname = $dbname;
                    if ($encoding != '') {
                        $encoding = strtolower(str_replace("-", "", $encoding));
                        $charsets = array();
                        $result = $this->dbh->query("SHOW CHARACTER SET");
                        while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
                            $charsets[] = $row["Charset"];
                        }
                        if (in_array($encoding, $charsets)) {
                            $this->dbh->query("SET NAMES '" . $encoding . "'");
                        }
                    }
                    $return_val = true;
                }
            }
        }
        return $return_val;
    }