Skip to content

Instantly share code, notes, and snippets.

View ssmusoke's full-sized avatar
♻️
In search of green builds

Stephen Senkomago Musoke ssmusoke

♻️
In search of green builds
View GitHub Profile
@ssmusoke
ssmusoke / gist:2133023
Created March 20, 2012 08:57
Person Class with relationship column and relationship
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
class Person {
/**
* @ORM\Column(type="string")
* @Assert\NotBlank(message = "person_firstname_error")
*/
protected $firstname = '';
/**
@ssmusoke
ssmusoke / gist:2240836
Created March 29, 2012 17:54
Family - Person not loading
<?php
/* File - Family.php */
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Family relationship
*
* @ORM\Entity
@ssmusoke
ssmusoke / Person.php
Created March 29, 2012 18:38
Model for Person
<?php
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Family relationship
*
* @ORM\Entity
* @ORM\Table(name="family")
@ssmusoke
ssmusoke / Family.php
Created March 29, 2012 18:39
Model for Family
<?php
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Profile for a person who will be included within a family tree
*
* @ORM\Entity
@ssmusoke
ssmusoke / gist:2241826
Created March 29, 2012 18:42
Offending Child Loading Code
<?php
$family = loadEntity('Family', 1); // wrapper for entity manager
// verify that there are more than one child
echo "There are ".count($family->getChildren())." children");
@ssmusoke
ssmusoke / Bootstrap.php
Created May 8, 2012 19:01
Zend Framework - Doctrine 2 integration using Bisna with Symfony 2 Validator configuration
<?php
use Doctrine\Common\ClassLoader;
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function _initDoctrine() {
$options = $this->getPluginResource('doctrine')->getOptions();
$container = new \Bisna\Doctrine\Container($options);
@ssmusoke
ssmusoke / SignupForm
Created May 10, 2012 04:24
Signup form - which does not render
<?php
/**
* Form for adding a signing up a user
*
*/
class SignUpForm extends Zend_Form
{
@ssmusoke
ssmusoke / gist:2667165
Created May 12, 2012 15:27
_call method for Getters and Setters
/**
* Execute getters and setters on the instance if they do not exist
*
* @param String $method The method to execute
* @param Array $args The method arguments
*
* @throws Exception if the property does not exist
*/
function __call($method, $args){
$attribute = strtolower(substr($method, 3, 1).substr($method, 4));
@ssmusoke
ssmusoke / gist:2707681
Created May 16, 2012 05:18
Test case for Cascading Tree Saves from root to child
function testTheTreeWithCascadesForRootandOneChild() {
$meta = $this->em->getClassMetadata(self::CATEGORY);
$root = new Category();
$root->setTitle("Root");
$this->assertTrue($root instanceof Node);
$child = new Category();
$child->setTitle("child");
$child->setParent($root);
@ssmusoke
ssmusoke / exception.txt
Created May 24, 2012 06:56
Category Table and Data with foreign key on root plus exception got
'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`gandaancestry`.`category`, CONSTRAINT `fk_category_root` FOREIGN KEY (`root`) REFERENCES `category` (`id`) ON DELETE SET NULL ON UPDATE SET NULL)' in D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\DBAL\Statement.php:131 Stack trace: #0 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\DBAL\Statement.php(131): PDOStatement->execute(NULL) #1 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\ORM\Persisters\BasicEntityPersister.php(239): Doctrine\DBAL\Statement->execute() #2 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\ORM\UnitOfWork.php(896): Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts() #3 D:\Program Files\Apache Group\Apache\htdocs\gandaancestry\library\Doctrine\ORM\UnitOfWork.php(304): Doctrine\ORM\UnitOfWork->executeInserts(Object(Doctrin