getDB(); $class = '\\MCMS\\Model\\Content'; $result = $db->table('content')->getObject(array('id' => $id), false, $class); return $result; } /** * stores an entry * update done if no row matching row for the follwing fields is found: id * @return stdClass the stored entry */ public static function storeContent(\MCMS\Model\Content $c) { $db = System::getInstance()->getDB(); $db->isTransactionSupported() and $db->startTransaction(); $keyfields = array('id' => $c->id); $oldSearch = $db->table('content')->select($keyfields); $doUpdate = $oldSearch->getRowCount() > 0; $oldSearch->close(); unset($oldSearch); // transient fields and sequence fields needs to be excluded $ignore = array('id'); if ($doUpdate) { $db->table('content')->update( $c, array('id' => $c->id), $ignore ); } else { $db->table('content')->insert( $c, $ignore ); $c->id = $db->getInsertId('id'); } $db->isTransactionSupported() and $db->commit(); return $c; } }