Skip to content

Instantly share code, notes, and snippets.

$response = parent::render();
$response->setContent(str_replace('a','b',$response->getContent()));
return $reponse;
function copy_row($fromid, $overwride = array()) {
$fom = $this->db->getTable('table')->find($fromid);
$to = $this->db->getTable('table')->create();
$to->fromArray(array_merge($overwride, $from->toArray()));
$to->save();
}
$new_row = copy_row(1, array('id' => null));
@haruta
haruta / gist:3332452
Created August 12, 2012 15:59
private method access for php using Reflection
<?php
class Ex1 {
private function private_method($val1 , $val2) {
return func_get_args();
}
}
$obj = new Ex1();
$r = call_private_method($obj, 'private_method', 'test1', 'test2');
@haruta
haruta / gist:2699870
Created May 15, 2012 07:58
apache combined access log parse by php
preg_match('/^([^ ]*) ([^ ]*) ([^ ]*) \[([^]]*)\] "([^ ]*)(?: *([^ ]*) *([^ ]*))?" ([^ ]*) ([^ ]*) "(.*?)" "(.*?)"/', $buf, $log_stat);
list($all, $host, $ident, $user, $time, $method, $resource, $proto, $status, $bytes, $referer, $agent) = $log_stat;
@haruta
haruta / seq num sql
Created March 8, 2012 11:00
有る親IDに対する連番をどうにかしたいSQL
create table t
(
id int auto_increment not null primary key,
parent_id int,
in_seq_num int
);
// parent_id 内の連番を in_seq_num に入れたい
set @lastid := 0;
set @number := 0;
<html>
<head>
<script language="javascript" type="text/javascript">
window.onload = function(){
var elements = document.getElementsByTagName('label');
for (var i=0; i <elements.length; i++) {
elements[i].onclick = function(){
var radios = this.getElementsByTagName('input');
for (var j=0;j<radios.length;j++) {
if (radios[j].getAttribute('type').toLowerCase() == 'radio') {