I made a posting today but on reflection it was the wrong list, the haxe
list for which I apologise!
Anyway, it concerned using mysql and neko.
The end result is the code I pasted here which may help somoebody else get
going!
What a fantastic toolkit neko/haxe is!
:)
Cheers guys!
Sean Charles
--- EXAMPLE CODE: Query a database and dumps the results ---
<code>
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// A simple wrapper for the MySQL function
calls.
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var db = {
connect => $loader.loadprim("[EMAIL PROTECTED]", 1 ) ,
close => $loader.loadprim("[EMAIL PROTECTED]", 1 ) ,
select_db => $loader.loadprim("[EMAIL PROTECTED]", 2 ) ,
request => $loader.loadprim("[EMAIL PROTECTED]", 2 ) }
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// A simple wrapper for the MySQL result set function
calls.
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var rset = {
handle => null ,
maxcols => 0 ,
get_length => $loader.loadprim("[EMAIL PROTECTED]", 1) ,
get_nfields => $loader.loadprim("[EMAIL PROTECTED]", 1),
next => $loader.loadprim("[EMAIL PROTECTED]", 1) ,
get => $loader.loadprim("[EMAIL PROTECTED]", 2) ,
get_int => $loader.loadprim("[EMAIL PROTECTED]", 2) ,
get_float => $loader.loadprim("[EMAIL PROTECTED]", 2)
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Prime the result set handler from a real
result.
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
result => function( result_set ) {
this.handle = result_set;
this.maxcols = this.get_nfields( result_set ); }
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Dump a single row of query
data.
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dump => function() {
while( $istrue( row = this.next( this.handle ))) {
this.dumprow( row, 0 ); }}
dumprow => function( row, column ) {
if ( column < this.maxcols ) {
$print( this.get( this.handle, column ));
$print( "\t" );
this.dumprow( row, column+1 ); }
else {
$print( "\n" ); }}};
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// MAIN ENTRY
POINT
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var dbconn =
db.connect({
host => "--domain-name--",
port => 3306,
user => "--user--",
pass => "--password--" });
if ( $istrue( dbconn )) {
db.select_db( dbconn, "matt_phi" );
rs = $new( rset );
rs.result( db.request( dbconn, "select * from domain_history"));
if ( $istrue( rs.handle )) {
rs.dump(); }
else {
$print( "Query failed\n"); }
db.close( dbconn ); }
else {
$print("Failed to connect"); }
</code>
--
Neko : One VM to run them all
(http://nekovm.org)