PGSQL and Errors ._.

Shadow121

Member
Messages
901
Reaction score
0
Points
16
I'm trying to make a database class and its being odd and not giving me an error when I try to use PGSQL yet it does with MySQLi and MySQL. Can someone help? e.e

PHP:
class database
{
    /**
     * The different databases supported
     * @access private
     */
    private $dbTypes = array("MySQL", "MySQLi", "PGSQL");

    /**
     * Current link
     * @access private
     */
    private $link;

    /**
     * Show Errors
     * @access private
     */
    private $ShowErrors;

    /**
     * Connect to the database
     * @param Host localhost
     * @param User root
     * @param Pass NULL
     * @param Data test_db
     * @param Persistant false
     * @param Errors true
     * @param Type MySQL
     */
    function dbConnect($host, $user, $pass, $data, $persistant, $errors, $type)
    {
    	$this->ShowErrors = $errors;
    	$type = (in_array($type, $this->dbTypes)) ? $type : "MySQL";
        if($type == 'MySQL'){
        	$this->link = ($persistant) ? @mysql_pconnect($host, $user, $pass) : @mysql_connect($host, $user, $pass);
        	@mysql_select_db($data, $this->link);
        	if($this->ShowErrors == true && mysql_error()){
        		echo "<strong>Error Found</strong>: ".mysql_error();
        	}
        }elseif($type == 'MySQLi'){
        	$this->link = mysqli_connect($host, $user, $pass, $data);
        	if($this->ShowErrors == true && mysqli_connect_error()){
        		echo "<strong>Error Found</strong>: ".mysqli_connect_error();
        	}
        }elseif($type == 'PGSQL'){
        	$this->link = ($persistant) ? pg_connect("host=$host port=5432 dbname=$data user=$user password=$pass") : pg_pconnect("host=$host port=5432 dbname=$data user=$user password=$pass");
        	if($this->ShowErrors == true && pg_last_error($this->link) != null){
        		print "<strong>Error Found: ".pg_last_error($this->link);
        	}
        }
    }
}
 
Last edited:

xmakina

New Member
Messages
264
Reaction score
0
Points
0
The thing with database errors is they're caused by your SQL AND your database itself, so you *really* need to tell us what your SQL command was and what the error was before people can, realistically, help.
 
Top