Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthortom
    • CommentTimeJan 14th 2008
     

    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

    • CommentAuthorKaste
    • CommentTimeJan 14th 2008
     

    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)?

    • CommentAuthortom
    • CommentTimeJan 15th 2008
     
    ok, I double-checked everything today. It really depends on the value I'm trying to set. Values 1 or 2 work as expected, but 0 doesn't.

    Might it be that there's a check via empty() somewhere which concludes that an integer 0 is empty and does not need to be saved?
    • CommentAuthorKaste
    • CommentTimeJan 15th 2008
     

    might share your unit test?

    one thing, what's the result of

    ->hasAttribute('my_attribute_name');  // = true?
    

    or:

    ->getAttributes();
    
    • CommentAuthortom
    • CommentTimeJan 15th 2008 edited
     

    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
    
    • CommentAuthorKaste
    • CommentTimeJan 15th 2008 edited
     

    works for me. just assumed

    Product: id, products_status int
    

    and a clean Model-Class

    • CommentAuthorasejua
    • CommentTimeJan 17th 2008
     

    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 :$

    • CommentAuthorKaste
    • CommentTimeJan 17th 2008
     

    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.

    • CommentAuthorKaste
    • CommentTimeJan 17th 2008
     

    ok, with

     products_status int not null
    

    I can reproduce this.

    • CommentAuthorKaste
    • CommentTimeJan 17th 2008
     

    thank you for finding this. please create a ticket.

    • CommentAuthorasejua
    • CommentTimeJan 19th 2008
     

    Thanks Kaste for fixing it and for your patience :)

    • CommentAuthortom
    • CommentTimeMar 11th 2008
     
    Ok, made a ticket.

    Sorry it took so long, and thanks for helping! :)

    Cheers,
    T.
Add your comments
    Username Password
  • Format comments as