Prev | Current Page 319 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

elementsNamed(???connection???))
{
if(el.get(???name???) == name)
{
if(el.get(???type???) == ???mysql???)
return getMySqlDbInfo(el);
else if(el.get(???type???) == ???sqlite???)
return getSqliteDbInfo(el);
else
return throw ???Invalid db type ??????+el.nodeName+?????™???;
}
}
return throw ???No db section has the attribute name equal to ??????+name+?????™???;
}
private static function getDefaultDatabaseName() : String
{
if(dbElement == null)
throw ???There is no ???db??™ section in the xml configuration file???;
// look for a connection element with the attribute ???default??™
// set to ???true??™
for(el in dbElement.elementsNamed(???connection???))
{
if((el.get(???default???)) == ???true???)
{
return if(el.exists(???name???))
165
Chapter 6: Organizing Your Code
el.get(???name???);
else
throw ???The default db tag has no name attribute???;
}
}
// if no one is found, throw an error
return throw ???No default database is defined???;
}
private static function getMySqlDbInfo(el : Xml) : DbInfo
{
var p : Xml = el.


Pages:
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331