Prev | Current Page 317 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

More than one connection can be defined in the XML and the
configuration can contain parameters for both MySQL and SQLite engines. The configuration class returns
a default connection configuration when the getDatabase() method is used without the name argument.
The method returns an anonymous object that contains the information defined in the XML file.
In the following example, two connections are configured but one or more can be used. Although no
formal validation is done in the class Config , the system will throw very specific errors if some
important information is missing or it will assume some default values when appropriate.
< config >
< db >
< connection name=???primary??? type=???mysql??? default=???true??? >
< mysql
host=???localhost???
user=???primaryuser???
pass=???mysecretpassword???
database=???MyDb??? / >
< /connection >
< connection name=???secondary??? type=???sqlite??? >
< sqlite
file=???local.db??? / >
< /connection >
< /db >
< /config >
The compilation command (or the hxml ) is modified to include the XML file:
> .


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