Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/01/2015, 15:52
pips
 
Fecha de Ingreso: octubre-2011
Mensajes: 104
Antigüedad: 15 años
Puntos: 1
Mensaje conexion, error SQLSTATE[HY000] [2002]

Hola esoy intentando configurar estos archivos en el servidor y me da este error:

archivo configuration.php
Código PHP:
class myweb {
    public static function 
configuration() {
        return 
$config = array(
            
"db" => array(
                    
"driver" => "mysql",
                    
"devel" => array(
                            
"host" => "zapato.com", //idem que localhost
                            
"port" => "",
                            
"username" => "zapatossss",
                            
"password" => "xxxxxx",
                            
"db" => "admincopia"
                    
),
                    
"real" => array(
                            
"host" => "zapato.com",
                            
"port" => "",
                            
"username" => "zapatossss",
                            
"password" => "xxxxxx",
                            
"db" => "admincopia"
                    
)
            ),
            
"urls" => array(
                    
"baseUrl" => "http://www.zapato.com/web/"
            
),
            
"contactData" => array(
                    
"mail_address" => "[email protected]"
            
)
        );
    }
}
defined("LIBRARY_PATH") or define("LIBRARY_PATH", realpath(dirname(__FILE__)));
defined("UTIL_PATH") or define("UTIL_PATH" , realpath(dirname(__FILE__) . '/util'));
ini_set("error_reporting", "true");
error_reporting(E_ALL|E_STRCT);
$config = myweb::configuration();
defined("ROOT_PATH") or define("ROOT_PATH", $config['urls']['baseUrl']);

function 
linkTo($innerUri){
    echo 
ROOT_PATH.$innerUri;
} 
Conexion Error:SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known Fatal error: Call to a member function prepare() on a non-object in /usr/home/zapato.com/web/lib/php/db/pdoConector.php on line 46

el archivo pdoConector.php

Código PHP:
require_once (realpath(dirname(dirname(dirname(__FILE__))) . "/configuration.php"));

abstract class 
pdoConector {
        
    private static 
$driver = "mysql"; //
    
private static $server = '';
    private static 
$port = '';
    private static 
$user = '';
    private static 
$pw = '';
    private static 
$db_name = '';
    private 
$pdoConnection ='';
    protected 
$cnx;
    
    protected function 
__construct(){                
        
$config = myweb::configuration();                
        
$this->driver = $config["db"]["driver"];
        
$selectedConector = $config["db"]["devel"];
        
$this->server = $selectedConector["host"];
        
$this->port = $selectedConector["port"];
        
$this->user = $selectedConector["username"];
        
$this->pw   = $selectedConector["password"];
        
$this->db_name = $selectedConector["db"];                
        
$this->pdoConnection = "$this->driver:host=$this->server;port=$this->port;dbname=$this->db_name;";                
        
//var_dump($this);        
        //echo $this->pdoConnection;        
    
}
    
    
    protected function 
getConect() {
        try {                        
            
//$this->cnx = new PDO ( $this->driver . ":host=" . self::$server . ";dbname=" . $this->db_name, self::$user, self::$pw, array (PDO::ATTR_PERSISTENT => TRUE ) );
            
$this->cnx = new PDO ( $this->pdoConnection,$this->user,$this->pw, array (PDO::ATTR_PERSISTENT => TRUE ) );
            return 
$this->cnx;
        } catch ( 
PDOException $ex ) {
            echo 
"Conexion Error:" . $ex->getMessage ();
        }
    }
            
    protected function 
doSelect($sql){
        try {
        
            
$consulta= $this->getConect()->prepare($sql); //-----LINEA 46---------
            
$consulta->execute();
            return 
$consulta;            
        } catch(
PDOException $e){
            echo 
"Conexion Error:".$e->getMessage();    
        }    
    }
        
    protected function 
closeConect(){
        
$this->cnx = null;
    }
    
}
?>

Desesperado!!!!! si alguien me puede echar un cable.....
Un saludo gracias