public function formObject() { $model = new Type($this->data->id); $this->data->forUpdate = $this->data->id != ''; $this->data->object = $model->getData(); $this->data->title = $this->data->forUpdate ? $model->getDescription() : _M("New Type"); $this->data->save = "@fnbr20/admin/type/save/" . $model->getId() . '|formObject'; $this->data->delete = "@fnbr20/admin/type/delete/" . $model->getId() . '|formObject'; $this->render(); }
public function update(Type $t) { $q = $this->_db->prepare('UPDATE Types SET libelle= :libelle WHERE id = :id'); $q->bindValue(':id', $t->getId(), PDO::PARAM_INT); $q->bindValue(':libelle', $t->getLibelle(), PDO::PARAM_STR); $q->execute(); }
/** * * @param Type $type * @return int id of the Type inserted in base. False if it didn't work. */ public static function flush($type) { $typeId = $type->getId(); $typeName = $type->getTypeName(); if ($typeId > 0) { $sql = 'UPDATE type t SET ' . 't.type_name = ?, ' . 'WHERE t.id_type = ?'; $params = array('si', &$typeName, $typeId); } else { $sql = 'INSERT INTO type ' . '(type_name) ' . 'VALUES(?) '; $params = array('s' & $typeName); } $idInsert = BaseSingleton::insertOrEdit($sql, $params); if ($idInsert !== false && $typeId > 0) { $idInsert = $typeId; } return $idInsert; }
public function updateType(Type $type) { try { if ($type != null && $type->getId() == null || $type == -1) { return false; } if (!parent::getBdd()->inTransaction()) { parent::getBdd()->beginTransaction(); } $query = "UPDATE TYPE SET label = :label WHERE id = :id"; $request = parent::getBdd()->prepare($query); $request->bindParam(':id', $type->getId()); $request->bindParam(':label', $type->getLabel()); $request->execute(); parent::getBdd()->commit(); $request->closeCursor(); return true; } catch (Exception $e) { error_log($e->getMessage()); } return false; }
/** * Declares an association between this object and a Type object. * * @param Type $v * @return Customer The current object (for fluent API support) * @throws PropelException */ public function setType(Type $v = null) { if ($v === null) { $this->setTypeId(NULL); } else { $this->setTypeId($v->getId()); } $this->aType = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Type object, it will not be re-added. if ($v !== null) { $v->addCustomer($this); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Type $value A Type object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Type $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
function test_find() { //Arrange $descript = "Event Keepsakes"; $descript2 = "Antiques"; $test_Type = new Type($descript); $test_Type->save(); $test_Type2 = new Type($descript2); $test_Type2->save(); //Act $result = Type::find($test_Type->getId()); //Assert $this->assertEquals($test_Type, $result); }