Skip to content

Instantly share code, notes, and snippets.

@michaelesmith
michaelesmith / gist:904589
Created April 5, 2011 21:22
Object Updates
<?php
public function save(Doctrine_Connection $conn = null) {
$conn = $conn ? $conn : $this->getTable()->getConnection();
$conn->beginTransaction();
try {
$ret = parent::save($conn);
$this->updateLuceneIndex();
$conn->commit();
@michaelesmith
michaelesmith / gist:804245
Created January 31, 2011 16:04
Problem fetching the same Doctrine object with two different queries
$lead_all = LeadTable::getInstance()->createQuery('l')->leftJoin('l.ToDoItems tdi')->where('l.id = ?', 7)->fetchOne();
echo count($lead_all->getToDoItems()); //prints 4
$NOT_LEAD_ALL = LeadTable::getInstance()->createQuery('l')->leftJoin('l.ToDoItems tdi')->where('l.id = ?', 7)->addWhere('tdi.close_date IS NOT NULL')->fetchOne();
echo count($lead_all->getToDoItems()); //prints 1 instead of 4 like above
class Something {
public function doSomthing(Lead $lead){
//code here
}
}