Wei, about the dynamic sql xml generation part of iBATIS, I've come up with an alternative way which feels strange but maybe better.. just an idea, something like this:
Code:
<insert id="person.insert.new" inputClass="Person" dynamic="true"><![CDATA[
if($object instanceof Member):
$sql = "insert into Persons (name, parent_id, email, join_date) values(:name, :parent, :email, :date)";
else:
$sql = "insert into Persons (name, parent_id, visit_date) values(:name, :parent, :date)";
endif;
]]></insert>
Basicly you write php code that set the $sql variable, good/bad/stupid/younameit? I feel that the "dynamic" tags in the iBATIS implementations are very well... cumbersome to work with, and I'd say that it's easier to express it in "raw" php as it's much easier to read and much much much faster since it gotta be interpreted on every request.
Edit:
Second edit, what about this idead:
<insert id="person.insert.new" inputClass="Person" generator="SQLGenerator::personInsertNew" /> you specify a generator tag in the xml which is a static call to a class, which allows you to do realy advanced logic to create your queries.
Edit:
Third edit, last idea to allow easy selection of differnet queries depending on insertClass:
Code:
<insert id="person.insert" inputClass="Person">
<if instanceof="Member" query="person.insert.member"/>
<if instanceof="Guest" query="person.insert.guest" />
</insert>
<insert id="person.insert.member" inputClass="Person">
insert into Persons (name, email, join_date, parent) values(:name, :email, :date, :parent)
</insert>
<insert id="person.insert.guest" inputClass="Person">
insert into Persons (name, visit_date, parent) values(:name, :date, :parent)
<insert>
so you don't have to use the generator-attribute for this, if you don't like what sitepoint does to the code and want syntax highlight, check here:
http://pastebin.se/2470
Bookmarks