SQL-relay module

From: Date: Tue, 27 Jun 2000 11:23:51 +0000
Subject: SQL-relay module
Groups: php.dev 
Request: Send a blank email to php-dev+get-22457@lists.php.net to get a copy of this message
Hi I've just written a dynamic loaded SQL-relay module for PHP4.0. SQL-relay is a new interface for MySQL, ORACE and some other databases which for examle supports cached-queries. More info on http://www.firstworks.com I implemented all API C functions with 2 changes: 1. in functions which send cached queries a name of cache file isn't passed by reference but returned as return string. 2. there aren't arguments which operate on variables in functions sending queries by file :-(. but I'll do it Tthe build procedure i got from PHP source and did some changes. This is first time that I wrote building program, so for sure it could be better. I added README and INSTALL text files to my archive with short description of using and installing this module. the static module I wrote too, but before I'll show it I want to make the code like PHP standards ( white spaces, new lines ... ) I'm attaching archive ready to install and some test scripts. What do you think about my module ? -- Adam -- _/ _/ _/_/_/ ----- Adam Kropielnicki, adasz@wp.pl ----- _/ _/ _/ _/ _/ Wirtualna Polska SA http://www.wp.pl _/_/_/_/ _/_/_/ _/ _/ _/ --------==* Moja WP: http://moja.wp.pl *==----------

Attachment: [application/x-gzip] mod_php_sql_relay.tar.gz
<?php dl("sql_relay.so"); $s=sqlrc_alloc("adasz",8000,"user1","password1",0,1); $r=sqlrc_sendQuery($s,"select table_name from user_tables"); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } ?> <?php $s=sqlrc_alloc("adasz",8000,"user1","password1",0,1); $r=sqlrc_sendQuery($s,"select * from t_rator"); sqlrc_sendEndOfSession($s); for ($i=0; $i<sqlrc_colCount($s); $i++) { echo(sqlrc_getColumnName($s,$i)); echo(" "); } echo("\n\n"); for ($a=0; $a<sqlrc_rowCount($s); $a++) { for ($i=0; $i<sqlrc_colCount($s); $i++) { echo(sqlrc_getFieldByIndex($s,$a,$i)); echo(" "); } echo("\n"); } sqlrc_free($s); ?> <?php $s=sqlrc_alloc("adasz",8000,"user1","password1",0,1); $r=sqlrc_sendFinalQuery($s,"select * from t_rator"); if($error=sqlrc_errorMessage($s)) { echo($error); echo("\n"); } else echo("no error\n"); $array=sqlrc_getRow($s,3); echo(sizeof($array)); echo("\n"); while(current($array)) { echo(current($array)); echo("\n"); next($array); } $array=sqlrc_getColumnNames($s); while(current($array)) { echo(current($array)); echo("\n"); next($array); } echo("\n"); echo(sqlrc_getColumnTypeByIndex($s,0)); echo("\n"); echo(sqlrc_getColumnTypeByName($s,"NAME")); echo("\n"); echo("\n"); echo(sqlrc_getColumnLengthByIndex($s,1)); echo("\n"); echo(sqlrc_getColumnLengthByName($s,"ID")); echo("\n"); sqlrc_debugOn($s); if(sqlrc_getDebug($s)) echo("Debug ON\n"); else echo("Debug OFF\n"); sqlrc_debugOff($s); if(sqlrc_getDebug($s)) echo("Debug ON\n"); else echo("Debug OFF\n"); sqlrc_free($s); ?> <?php $s=sqlrc_alloc("adasz",8000,"user1","password1",0,1); $cachefile=sqlrc_sendCachedQuery($s,1,"select table_name from user_tables"); echo $cachefile; echo("\n"); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } $cachefile=sqlrc_sendCachedFinalQuery($s,1,"select table_name from user_tables"); echo $cachefile; echo("\n"); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } echo("\n"); $r=sqlrc_openCachedResultSet($s,$cachefile); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } ?> <?php $s=sqlrc_alloc("adasz",8000,"user1","password1",0,1); $r=sqlrc_sendFileQuery($s,"/root/work/sql-relay/php-4.0.0","filequery.sql"); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } $r=sqlrc_sendFinalFileQuery($s,"/root/work/sql-relay/php-4.0.0","filequery.sql"); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } ?> <?php $s=sqlrc_alloc("adasz",8000,"user1","password1",0,1); $filename=sqlrc_sendCachedFileQuery($s,1,".","filequery.sql"); echo $filename; echo("\n"); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } $r=sqlrc_openCachedResultSet($s,$filename); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } $filename=sqlrc_sendCachedFinalFileQuery($s,1,".","filequery.sql"); echo $filename; echo("\n"); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } $r=sqlrc_openCachedResultSet($s,$filename); for ($i=0; $i<sqlrc_rowCount($s); $i++) { printf("%s\n",sqlrc_getFieldByName($s,$i,"table_name")); } ?>
« previous php.dev (#22457) next »