<div><br></div>I have two databases that are very similar. For example, the "person" table in one db has an "email" column and the other does not have that column, otherwise the tables are the same.<div>
<br></div><div>My application uses the schema with the table that has the "email" column, so there's places in the application that call $person->get_column( 'email' ), and also $person_rs->create( { name => $name, email => $email } ); </div>
<div><br></div><div>Now, I want to use the second schema with the same application, but as mentioned above does not have an "email" column on the person table. it's not important that the column does not exist.</div>
<div><br></div><div>My question is what can I do to make get_column and create (and other methods that assume there is an "email" column) work without this column defined in the result class. Is there any way to have define a column that is never used when constructing database queries?</div>
<div><br></div><div><br></div><div>I can create a method in the result class of the schema that doesn't have that column:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div>sub email { return '<a href="mailto:dummy@example.com">dummy@example.com</a>' }</div></blockquote><div><br></div><div>And that will handle $person->email and even $person->email( $new_email ), although I don't see that ever being used.</div>
<div><br></div><div>I'm not sure how to best override get_column(), though. I suppose the best approach would be to replace all the get_column() calls in the application with actual method calls (i.e. ->email). Or is there a way to override get_column in this case?</div>
<div><br></div><div>What about the create() method? Use an "around create => sub {}" in the ResultClass and strip out the "email" column?</div><div><br></div><div><br></div><div><br><div><div><br>
-- <br>
Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a><br>
</div></div></div>