readRelationshipFormat
package
enum readRelationshipFormat =
q{
if (relationship.sql)
{
model.%1$s = (getMySqlAdapter!%3$s).readMany(relationship.sql, null);
}
else if (relationship.members)
{
auto params = getParams();
string[] whereClause = [];
static foreach (memberLocal,memberRemote; relationship.members)
{
mixin("whereClause ~= \"`" ~ memberRemote ~ "` = @" ~ memberLocal ~ "\";");
mixin("params[\"" ~ memberLocal ~ "\"] = model." ~ memberLocal ~ ";");
}
import std.array : join;
model.%1$s = (getMySqlAdapter!%3$s).readMany("SELECT * FROM `@table` WHERE " ~ whereClause.join(" AND "), params);
}
};
The format for reading relationships.