Skip to content

Instantly share code, notes, and snippets.

Avatar
🤩
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik

Abdul Malik Ikhsan samsonasik

🤩
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik
View GitHub Profile
@samsonasik
samsonasik / gist:9067872
Created February 18, 2014 09:59
uniq loop file do command
View gist:9067872
for f in *.sql; do mysql -u root databasename < $f; done;
@samsonasik
samsonasik / gist:9475960
Created March 10, 2014 22:38
always use getSqlStringForSqlObject with sql object
View gist:9475960
use Zend\Db\Sql;
$sql = new Sql\Sql;
$select = $sql->select($table);
$select->offset(10);
echo $sql->getSqlStringForSqlObject($select);
@samsonasik
samsonasik / gist:9759243
Created March 25, 2014 10:52
git archive changed file
View gist:9759243
tar czf changed-files.tar.gz `git diff --name-only HEAD`
@samsonasik
samsonasik / gist:514cb5333e7ed12875fe
Last active August 29, 2015 14:01
abstract sql object
View gist:514cb5333e7ed12875fe
<?php
use Zend\Db\Sql\Sql;
$sql = new Sql($adapter);
$oSelect = $sql->select('table_test');
$oSelect->columns(array('*'))->where(array('test' => 'ok')->limit(1);
$sqlString = $sql->getSqlStringForSqlObject($oSelect);
//see https://github.com/zendframework/zf2/issues/3224
@samsonasik
samsonasik / zfcuser-bjyauthorize-set-role-after-register-Module.php
Created June 24, 2014 16:37
ZfcUser - BjyAuthorize : set role after register
View zfcuser-bjyauthorize-set-role-after-register-Module.php
// adopted from http://stackoverflow.com/questions/17596639/zfcuser-add-user-role-after-registration
/** set role after register
*
*/
public function onBootstrap(EventInterface $e)
{
$services = $e->getApplication()->getServiceManager();
$zfcServiceEvents = $services->get('zfcuser_user_service')->getEventManager();
$zfcServiceEvents->attach('register', function($e) use ($services) {
@samsonasik
samsonasik / consoleenvzf2.php
Created June 25, 2014 01:31
disable some module in console environment in ZF2
View consoleenvzf2.php
<?php
use Zend\Console\Console;
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
View gist:6124a8aca370e27ffc38
$array = array();
foreach($entities as $entity) {
$array[] = array(
'id' => $entity->getId(),
'municipio' => $entity->getMunicipio(),
);
}
return $array;
View Module.php
<?php
namespace Application;
use Zend\Mvc\MvcEvent;
use Zend\Validator\AbstractValidator;
class Module
{
public function onBootstrap(MvcEvent $event)
@samsonasik
samsonasik / EntityManagerFactory.php
Created August 11, 2014 22:36
register doctrine extension in zf2 doctrine module
View EntityManagerFactory.php
<?php
namespace Common\Service;
use Doctrine\ORM\EntityManager;
use DoctrineModule\Service\AbstractFactory;
use Zend\ServiceManager\ServiceLocatorInterface;
class EntityManagerFactory extends AbstractFactory
{
@samsonasik
samsonasik / 1. composer.json
Last active August 29, 2015 14:06
zendservice-recaptcha
View 1. composer.json
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {