Ref. URL:
Programming with SQL Relay using the PHP API
// $tsdb_dsn = 'sqlrelay://AAAA:BBBB@CCCC:9000'; // dl("sql_relay.so"); $sql =" select tag1,tag2,val from TBL_SITE_REPORT_DAY t where xdate=to_date('20180906','yyyymmdd') and tag1='top_item@0005' order by val desc "; $con=sqlrcon_alloc("CCCC",9000,"","AAAA","BBBB",0,1); $cur=sqlrcur_alloc($con); sqlrcur_sendQuery($cur, $sql ); sqlrcon_endSession($con); $fields = array(); for ($i=0; $i<sqlrcur_colCount($cur); $i++) { $fields[] = sqlrcur_getColumnName($cur,$i); } print_r( $fields ); if ( sqlrcur_rowCount($cur) ) { echo "row count " . sqlrcur_rowCount($cur) . "\n"; for ($row=0; $row<sqlrcur_rowCount($cur); $row++) { for ($col=0; $col<sqlrcur_colCount($cur); $col++) { echo sqlrcur_getField($cur,$row,$col); echo ","; } echo "\n"; } } sqlrcur_free($cur); sqlrcon_free($con);