0

I'm using Zend_Db_Table_Abstract to connect to my db with the following init code in the constructor of my class (that extends Zend_Db_Table_Abstract):

$db = new Zend_Db_Adapter_Pdo_Mysql(array(
        'host'     => 'CLOUD.SQL.IP.ADRESS',
        'username' => 'username',
        'password' => 'password',
        'dbname'   => 'db',
        'charset'  => 'UTF8'
    ));

    Zend_Db_Table_Abstract::setDefaultAdapter($db);
    parent::__construct();

That works well on local where i connect using the ip of the instance, but seems like on production i'm forced to use unix socket with one of following options:

//PDO_MySQL 
$db = new pdo('mysql:unix_socket=/cloudsql/<your-project-id>:<your-instance-name>;dbname=<database-name>',
  'root',  // username
  ''       // password
  );

//mysqli 
$sql = new mysqli(null,
  'root', // username
  '',     // password
  <database-name>,
  null,
  '/cloudsql/<your-project-id>:<your-instance-name>'
  );

//MySQL API 
$conn = mysql_connect(':/cloudsql/<your-project-id>:<your-instance-name>',
  'root', // username
  ''      // password
  );
mysql_select_db('<database-name'>);

My issue is that i'm not sure how to initialize Zend_Db_Table_Abstract to use the socket instead the host, as all the approach i have tried were unsuccessful.

Thanks for you help in advance.

J

  • possible duplicate of [Google App Engine: How to connect to Cloud SQL with Zend DB](http://stackoverflow.com/questions/20088455/google-app-engine-how-to-connect-to-cloud-sql-with-zend-db) – Nick Dec 10 '14 at 18:17
  • similar field but not the same i'm afraid – Javi Cebrián Dec 11 '14 at 18:22
  • My best advice at this point is to try to see if you can construct your Zend_Db_Adapter_Pdo_Mysql using the `new Zend_Config(... driver_options ...)` code from the almost-duplicate question, since that does seem to work with unix-sockets. Best of luck. – Nick Dec 11 '14 at 18:46

0 Answers0