Hi,
it may seem strange, but I can't get akelos to set an integer attribute in my tables to the value 0.
I have a products table and model with a 'products_status' field. However,
$product->updateAttribute( 'products_status', n);
works for n != 0 only!
Any idea why?
Tom
hm, updateAttribute() just calls setAttribute($attribute_name,$value) then saves.
actually, in the end it does a simple $this->$attribute_name = $value;
so, could you double-check spelling. do you have a explicit setter (like setProductsStatus)?
might share your unit test?
one thing, what's the result of
->hasAttribute('my_attribute_name'); // = true?
or:
->getAttributes();
Ok, heres the test case code:
function test_Product()
{
$prod = new Product( array( 'products_status' => 2 ));
print_r( $prod->getAttributes() );
$this->assertTrue( $prod->hasAttribute('products_status'),'Attribute doesnt exist.');
$this->assertTrue( $prod->save(),'Saving the product failed. :(');
$prod = $prod->find('first');
$prod->updateAttribute( 'products_status', 0 );
$prod = $prod->find('first');
$this->assertTrue( $prod->products_status == 0,'Setting to 0 failed. products_status is '.$prod->products_status);
}
The last assertion fails, saying:
1) Setting to 0 failed. products_status is 2
print_r output includes
[products_status] => 2
works for me. just assumed
Product: id, products_status int
and a clean Model-Class
I've placed a new post about this topic (sorry for that, founded this one later)
I'm having the same problem Tom has and I've traced the place where the "problem" happens.
Can you explain your last message (the Product: ... and a clean Model-Class thing), I'm still feel newb with Akelos :)
Thanks and sorry for the doubled post :$
Can you explain your last message (the Product: ... and a clean Model-Class thing)
table products has two columns: id & products_status. Both int's.
the model is 'clean', without associations, validations etc.
ok, with
products_status int not null
I can reproduce this.
thank you for finding this. please create a ticket.
Thanks Kaste for fixing it and for your patience :)
I realize this is an old thread, but I'm still having trouble updating a field to the value of '0'. It just does not save it. I guess I can add my own save callback (one of the onSave or onValidate ones) code that actually performs it's own SQL update query for the field changing to 0, but that's kinda silly.
ok, I take that back. The value of 0 or NULL does get sent to the database. It's working!!
1 to 14 of 14