This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » [SOLVED] propel - modified fields, old values
[SOLVED] propel - modified fields, old values [message #103166] Wed, 28 July 2010 11:11 Go to next message
enigma
Messages: 94
Registered: March 2007
Location: Poland
Member
In doctrine I can check modfied fields and I get old values with
->getModified(true);


Can I do the same with propel. I found only function to check if fields or one field are modified in class extending base model.
->getModifiedColumns()

It is possible to get old values? I use propel 1.5

[Updated on: Wed, 28 July 2010 16:28]


Paweł Ryznar - programista JAVA :: Love IT - devBlog
Re: propel - modified fields, old values [message #103185 is a reply to message #103166 ] Wed, 28 July 2010 12:41 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
hello,

i don't think propel have this functionality.

If you really need it you could post it as a request in propel dev groupe, that could be a good new behavior or directly in propel core.
Re: propel - modified fields, old values [message #103193 is a reply to message #103166 ] Wed, 28 July 2010 15:18 Go to previous messageGo to next message
enigma
Messages: 94
Registered: March 2007
Location: Poland
Member
ok, so how to retrieve old value with own code?
This code cause that value from database ($oldImage) overwrite value from form ($newImage):
abstract class BaseBook extends BaseObject  implements Persistent
	    public function updateImage() {
               $old = BookPeer::retrieveByPK($this->getId());
               $oldImage = $old->getImage();
               $newImage = $this->getImage();


Paweł Ryznar - programista JAVA :: Love IT - devBlog
Re: propel - modified fields, old values [message #103197 is a reply to message #103193 ] Wed, 28 July 2010 15:42 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
i m not sure where this code come from but you could just do :
$book = BookQuery::create()->findPk(1);
$book->oldValues = $book->toArray(); //(i dont remember exactly if it s "toArray()")
Re: propel - modified fields, old values [message #103200 is a reply to message #103166 ] Wed, 28 July 2010 16:00 Go to previous messageGo to next message
enigma
Messages: 94
Registered: March 2007
Location: Poland
Member
this code is in model, you can see class BaseBook on previous code.
Your tip also doesn't help, I have still the same values in both variables.
=============================
SOLVED
This is solution:
$this->getPeer()->removeInstanceFromPool($this);
$old =  $this->getPeer()->retrieveByPK($this->getId())->getImage();
$new = $this->getImage();

[Updated on: Wed, 28 July 2010 16:27]


Paweł Ryznar - programista JAVA :: Love IT - devBlog
Re: propel - modified fields, old values [message #103204 is a reply to message #103200 ] Wed, 28 July 2010 17:14 Go to previous message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
well what i meant was saving after you get your object the initial value in a dynamic property called oldValues so you dont have to remove from the cache the object and do an extra request to the db :
$book = BookQuery::create()->findPk(1);
$book->oldValues = $book->toArray(); //(i dont remember exactly if it s "toArray()")

$book->setImage('image1');
$new_image = $book->getImage();
$old_image = $book->oldValues['image'];
Previous Topic:Retrieve a doctrine field type
Next Topic:Issues with propel:build on Propel 1.5
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software