Skip to content

Instantly share code, notes, and snippets.

@phpdave
phpdave / EmailValueObjectExample.php
Last active August 26, 2015 15:08
Playing around with Value Objects
<?
class EmailValue
{
protected $value;
public function __construct($emailAddress)
{
//sanitize for DB (NULL bytes, HTML and PHP tags stripped)
$emailAddress = strip_tags($emailAddress);
//Supposedly does more than strip tags
$emailAddress = xss_clean($emailAddress);
@phpdave
phpdave / HandleFileLock.php
Last active August 28, 2015 02:33
Handling the DB2 record lock exception in PHP when updating a record that has a lock.
<?
try
{
$user="BOB";
$id="2";
$db=new PDO("ReplceW/ConnectionString");
$stmt=$db->prepare("UPDATE `users` SET user=:user WHERE ID =:ID");
$stmt->bindParam(":user",$user);
$stmt->bindParam(":id",$id);
$stmt->execute();
@phpdave
phpdave / Zend Framework 2 - PHPLoc
Last active August 29, 2015 14:08
PHPLoc of Zend Framework 2.3.3 - Oct 30 2014
====ZF2.3.3 PHPLoc====
\htdocs\vendor\zendframework>php phploc.phar --log-csv log.csv --progress .
phploc 2.0.6 by Sebastian Bergmann.
Directories 417
Files 2389
Size
Lines of Code (LOC) 304378
Comment Lines of Code (CLOC) 111994 (36.79%)
@phpdave
phpdave / Zend Framework 1.7 - PHPLoc-
Last active August 29, 2015 14:08
PHPLoc of Zend Framework 1.7
Directories 352
Files 1712
Size
Lines of Code (LOC) 337972
Comment Lines of Code (CLOC) 152185 (45.03%)
Non-Comment Lines of Code (NCLOC) 185787 (54.97%)
Logical Lines of Code (LLOC) 61708 (18.26%)
Classes 59208 (95.95%)
\vendor\symfony\symfony\src\Symfony\Component>php phploc.phar --log-csv log.csv --progress .
phploc 2.0.6 by Sebastian Bergmann.
Directories 449
Files 2417
Size
Lines of Code (LOC) 283341
Comment Lines of Code (CLOC) 66130 (23.34%)
Non-Comment Lines of Code (NCLOC) 217211 (76.66%)
\vendor\symfony\symfony\src\Symfony\Component>php phploc.phar --log-csv log.csv --progress .
phploc 2.0.6 by Sebastian Bergmann.
Directories 449
Files 2417
Size
Lines of Code (LOC) 283341
Comment Lines of Code (CLOC) 66130 (23.34%)
Non-Comment Lines of Code (NCLOC) 217211 (76.66%)
@phpdave
phpdave / Zend Framework 1.7 - PHPLoc-
Created October 30, 2014 16:29
PHPLoc of Zend Framework 1.7
Directories 352
Files 1712
Size
Lines of Code (LOC) 337972
Comment Lines of Code (CLOC) 152185 (45.03%)
Non-Comment Lines of Code (NCLOC) 185787 (54.97%)
Logical Lines of Code (LLOC) 61708 (18.26%)
Classes 59208 (95.95%)
Average Class Length 36
@phpdave
phpdave / Zend Framework 2 - PHPLoc
Created October 30, 2014 16:29
PHPLoc of Zend Framework 2.3.3 - Oct 30 2014
====ZF2.3.3 PHPLoc====
\htdocs\vendor\zendframework>php phploc.phar --log-csv log.csv --progress .
phploc 2.0.6 by Sebastian Bergmann.
Directories 417
Files 2389
Size
Lines of Code (LOC) 304378
Comment Lines of Code (CLOC) 111994 (36.79%)
@phpdave
phpdave / test.php
Last active August 29, 2015 14:08
Simple PHP script to pull SQL Special Register values from the IBM DB2 via the commandline QP2TERM
<?php
// Call this script in pase using:
// Call QP2TERM
// /usr/local/zendsvr/bin/php-cli /www/zendsvr/htdocs/test.php
// This script will use the current user thats logged in and the default database.
// Note: We can't use $_SERVER['APP_ENV'] because PHP-CLI doesn't get that value.
// That value is set by Apache on web requests
$db2Connection = db2_connect( '', '' , '',array());
@phpdave
phpdave / model.php
Last active August 29, 2015 14:09
ZF1 Model column with a #
<?php
class Model
{
protected $_dbh = null;
protected $_table = 'MYTABLE';
public function __construct()
{