Skip to content

Instantly share code, notes, and snippets.

Matthew Setter settermjd

Block or report user

Report or block settermjd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@settermjd
settermjd / gist:5802655
Created Jun 18, 2013
Creating a nested SQL query with \Zend\Db\Sql
View gist:5802655
$select->where(array("ItemID" => (int)$itemId));
$select->where->and->nest
->like('FirstName', $inputFilter->getValue("searchCriteria") . "%")
->or->like('FirstName', "%" . $inputFilter->getValue("searchCriteria"))
->or->like('LastName', $inputFilter->getValue("searchCriteria") . "%")
->or->like('LastName', "%" . $inputFilter->getValue("searchCriteria")
);
@settermjd
settermjd / gist:6778757
Last active Dec 24, 2015
Handle Umlauts and other characters in DOMPDF
View gist:6778757
$pdf = new DOMPDF();
$pdf->load_html(utf8_decode($customtext));
@settermjd
settermjd / gist:6822388
Created Oct 4, 2013
A, rather elementary, way of finishing the current git flow feature
View gist:6822388
git flow feature finish $( git flow feature list | sed 's/^* //g' )
View GenericTable.php
<?php
namespace Generic\Model;
use Zend\Db\Sql\Predicate\Predicate;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;
class GenericTable
{
protected $tableGateway;
@settermjd
settermjd / GenericTableTest.php
Created Nov 6, 2013
A simple Zend Framework model class, used to build a set of unit tests with PHPUnit and Mockery.
View GenericTableTest.php
<?php
namespace Generic\Model;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;
class GenericTable
{
protected $tableGateway;
@settermjd
settermjd / GenericTableTest.php
Created Nov 6, 2013
Using Mockery with PHPUnit for creating mocks when testing a Zend Framework model class
View GenericTableTest.php
<?php
namespace GenericTest\Model;
use Generic\Model\GenericTable;
use Generic\Model\Generic;
use Zend\Db\ResultSet\ResultSet;
use PHPUnit_Framework_TestCase;
use Zend\Db\Sql\Predicate\Predicate;
use Zend\Db\Sql\Select;
use \Mockery as m;
@settermjd
settermjd / where-mock.php
Last active Dec 29, 2015
I'm having trouble mocking "$select->where->greaterThanOrEqualTo" with Zend\Db\Sql. Hope someone can shed light on this.
View where-mock.php
/*
* Here's the function call.
* $searchCriteria is an instance of \Zend\InputFilter\InputFilter
*/
$select->where->greaterThanOrEqualTo(
"EventDate", new \Zend\Db\Sql\Expression(
"STR_TO_DATE('" . $searchCriteria->getValue("startDate") ."','%m-%d-%Y')"
)
);
@settermjd
settermjd / simple-tablegateway-class
Last active Dec 29, 2015
Rather basic TableGateway class
View simple-tablegateway-class
namespace MaltBlue\Model;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Select;
class CountryDebtTable extends QuickSearchTable
{
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
View gist:7629594
namespace MaltBlue\Model;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
use MaltBlue\Filter\Float;
class CountryDebt implements InputFilterAwareInterface
{
View gist:7629664
public function getServiceConfig()
{
return array(
'CountryDebtTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$hydrator = new \MaltBlue\Hydrator\TableEntityMapper(array(
'CountryID' => 'countryId',
'DebtId' => 'debtId',
'DebtLevel' => 'debtLevel',
));
You can’t perform that action at this time.