[CDBI] Re: How do I use deflate?
Edward J. Sabol
sabol at alderaan.gsfc.nasa.gov
Fri Jun 1 23:36:40 BST 2007
> I can update the location_id field for a host just fine like this:
> $host->location_id(1); # or some other location's primary key
> I want to be able to update the location_id field for a host like so:
> From what I have gathered from the docs, I should be able to use deflate
> in has_a to do the translation from SomeLocationName to that location's
> ID/primary key. It seems like it should be as simple as:
> Host->has_a(location_id => 'Location',
> deflate => 'id');
> This should call the Location object's id method before update the
> location_id column of the host table, right? If I'm being an idiot,
> please set me straight.
You shouldn't use deflation for this. The ->location_id() method should
return an object of type Location if you have the has_a() relationship
configured correctly. In order to change the name of the location of $host,
you would then do the following:
After which, you need to commit the transaction to the database, if you're
using transactions, or issue a ->update() if 'autoupdate' mode is not active.
Hope this helps,
More information about the ClassDBI