Using Zend_Db_Table_Abstract with Google App Engine Cloud SQL

85 views Asked by At

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

0

There are 0 answers