Skip to content

Instantly share code, notes, and snippets.

View datiecher's full-sized avatar

Daniel Anderson Tiecher datiecher

View GitHub Profile
<?php
protected function doModifyLimitQuery($query, $limit, $offset = null)
{
if ($limit > 0) {
if ($offset == 0) {
$query = preg_replace('/^(SELECT\s(DISTINCT\s)?)/i', '\1TOP ' . $limit . ' ', $query);
$query = preg_replace('/FROM \(SELECT/i', 'FROM (SELECT TOP 2000000000', $query);
} else {
$orderby = stristr($query, 'ORDER BY');
@datiecher
datiecher / fails.js
Created February 18, 2012 12:35
Simple Backbone Test Case
(function($){
window.app = {
init: function() {
app.router = new app.Router();
Backbone.history.loadUrl = function(fragmentOverride) {
var fragment = this.fragment = this.getFragment(fragmentOverride).replace(/^.+\.php\/?/, '');
console.log('Navigated URL: '+fragment);
var matched = _.any(this.handlers, function(handler) {
if (handler.route.test(fragment)) {
@datiecher
datiecher / app.js
Created February 18, 2012 11:33
loadUrl version that removes a php front controller from the url
Backbone.history.loadUrl = function(fragmentOverride) {
var fragment = this.fragment = this.getFragment(fragmentOverride).replace(/^.+\.php\/?/, '');
var matched = _.any(this.handlers, function(handler) {
if (handler.route.test(fragment)) {
handler.callback(fragment);
return true;
}
});
return matched;
@datiecher
datiecher / Application.php
Created November 7, 2011 10:46
This class example is by no means complete. It simply functions as a data object but it lacks input sanitization, filtering, only have some kind of validation. If needed I would gladly work on a more complete example. =)
<?php
/**
* This class example is by no means complete. It simply functions as a data object
* but it lacks input sanitization, filtering, only have some kind of validation.
* If needed I would gladly work on a more complete example
*
* @throws EternalWow\Model\Exception
*/