Skip to content

Instantly share code, notes, and snippets.

View billschaller's full-sized avatar

Bill Schaller billschaller

  • Facebook
  • New York, NY
View GitHub Profile
@billschaller
billschaller / .block
Last active May 5, 2017 17:50 — forked from mbostock/.block
Line Chart
license: gpl-3.0
@billschaller
billschaller / QueryBuilderCteTrait.php
Created January 11, 2016 14:29
QueryBuilder with CTE
<?php
namespace Data;
use Data\CampaignData\Query\AssignmentQueryBuilder;
trait QueryBuilderCteTrait
{
protected $ctes = [];
@billschaller
billschaller / gist:90e4b4d6414fbf2b0e68
Created March 18, 2015 17:55
fast array hydration for single entities, no associations, no type conversions
/**
* {@inheritdoc}
*/
protected function hydrateAllData()
{
$firstRowData = $this->_stmt->fetch(PDO::FETCH_ASSOC);
$headings = array_keys($firstRowData);
$fields = [];
foreach($headings as $idx => $column) {
$colInfo = $this->hydrateColumnInfo($column);
@billschaller
billschaller / gist:fddde9efd4c2b675b952
Created March 17, 2015 22:04
doModifyLimitQuery changes
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@billschaller
billschaller / JsonHelper.php
Last active August 29, 2015 14:03
How to json_encode Doctrine (or other) model objects nicely without recursion issues.
<?php
/**
* Class JsonHelper
*
* Handles json_encoding Model objects in a way that prevents recursion issues. Stores hashes of
* "seen" objects, and if an object has already been seen, the JsonSerializableTrait unsets the key
* of the duplicate object.
*
*/
class JsonHelper