ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

The following problem in MySQL for Mac:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

It’s solved by doing:

$ sudo chown -R _mysql /usr/local/var/mysql
$ sudo chmod -R o+rwx /usr/local/var/mysql

How to install PHP-IMAP extension in Mac

I’ve finally found the solution. Most of it was here:

My machine is a late 2011 Macbook Pro with MacOSX 10.7.4, PHP 5.4. installed via these instructions:

Here’s a step-by-step for those with a similar or identical setup:

Download the imap source from this url, focus on the one with the most recent date which doesn’t end in “Z”:

Unarchive, go into folder, run the following commands:

$ make osx EXTRACFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"

The above command will throw a bunch of warnings at you, but should complete sucessfully, unlike the command originally suggested in the september28 blog post.

Next, do the following:

$ sudo cp c-client/*.h /usr/local/include/
$ sudo cp c-client/*.c /usr/local/lib/
$ sudo cp c-client/c-client.a /usr/local/lib/libc-client.a

Once this is done, go into the downloaded php source folder if you made a custom upgrade like I did (as per the second link in the answer) and build the extension for your system. If you didn’t build a custom version, just download the PHP source for the version you have installed, and use that, it doesn’t matter.

$ cd ~/Downloads/Php-5.4.4/ext/imap
$ phpize
$ ./configure --with-imap==/usr/local/imap-2007 --with-kerberos --with-imap-ssl
$ make

Once done, do the following:

$ sudo cp modules/ /usr/lib/php/extensions/no-debug-non-zts-20100525/

…or if your PHP extension folder is different, put that (you can see the location in phpinfo(); )

Restart apache and you should be ready to go.

$ sudo apachectl restart

Exists statement for ZF2

In the next example you´ll see how to use an exists stament and how to use subqueries in ZF2.

$adapter = $this->tableGateway->adapter;
$sql = new Sql($adapter);

$campos = array(
	'fecha_generacion' => 'fecha_generacion',
	'numero_envio' => new Expression('max(numero_envio)')

$subSelect = $sql->select();
$subSelect->from(array('b' => 'documento_resumen'))
		->where('b.codigo_empresa = a.codigo_empresa')
		->where('b.tipo_documento = a.tipo_documento')
		->where('b.fecha_generacion = a.fecha_generacion')
		->where('b.codigo_respuesta = \'0\'');

$select = $sql->select()
	->from(array('a' => 'documento_resumen'))
				'a.codigo_empresa' => $codigoEmp,
				'a.tipo_documento' => $tipoDoc,
				'a.codigo_respuesta' => '2'
		new \Zend\Db\Sql\Predicate\Expression(
		  "NOT EXISTS(" . @$subSelect->getSqlString($adapter->getPlatform()) . ")"

// Run the query
$statement = $sql->prepareStatementForSqlObject($select);
$result = $statement->execute();

return ArrayUtils::iteratorToArray($result);

Error 2325 SUNAT

Para quienes hayan o estén trabajando en integración con documentos electrónicos con SUNAT es muy probable que tengan el siguiente error:

2325      El certificado usado no es el comunicado a SUNAT

Esto es debido a que SUNAT al parecer usa un caché de 1 día entonces si subieron un nuevo certificado y tratan de generar un documento en ese mismo instante obtendran este error.

Para poder usar el certificado subido deben esperar 1 día despues de haber subido el certificado.

Recompile Interbase for Mac

Add to MAMP / OSX

get xcode and macports.
install m4 through macports
download php-source corresponding to mamp-version

create symblinks needed

# in short:
# (backslash = keep on same row)
cd /usr
sudo  mkdir -p local/firebird/lib

sudo ln -s /Library/Frameworks/Firebird.framework/Firebird \

sudo ln -s /Library/Frameworks/Firebird.framework/Headers/ \

#create .so
sudo su

cd /path-to-php-source/ext/interbase


./configure –with-interbase=/usr/local/firebird


#install so to mamp-ext.dir
cp modules/ \
/Applications/MAMP/bin/php5/lib/ \

#add to /Applications/MAMP/conf/php5/php.ini
extension =
ibase.allow_persistent = “1”
ibase.max_persistent = “-1”
ibase.max_links = “-1”
ibase.default_db = null
ibase.default_user = NULL
ibase.default_password = NULL
ibase.default_charset = NULL
ibase.timestampformat = “%Y-%m-%d %H:%M:%S”
ibase.dateformat = “%Y-%m-%d”
ibase.timeformat = “%H:%M:%S”

#restart mamp – interbase should show in phpinfo