SQL

Pierre Sahores psahores at easynet.fr
Thu May 23 17:38:00 EDT 2002


Simon Lord a écrit :
> 
> Anyone have a sample stack that can read and write to a mysql
> DB?  I'd like to see one in action, I guess that would mean
> buying some form of external since this feature is not native to
> MetaCard.  Please include that info as well if possible.
> 
> Thanks.
> 
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard

As previously sent to the list (natively only suitable with PostGreSQL),


The MC side :

> on SQLbyMC
>   global Retour
>   if the num of words in fld "Saisie" of stack "Procedures" is "0" then pass SQLbyMC # the field where the SQL request statements have to be writen
>   put "&r=" & fld "Saisie" of stack "Procedures" & "zzzzzzzzzzzzzzzzzzzzzz" into dbAsked
>   set httpheaders to "Content-Type: application/x-www-form-urlencoded" & cr & "Content-Length:" && the length of dbAsked & cr & cr # Apache :oui ; IIS : non
>   post dbAsked to url "http://localhost/wmctopg.xml"
>   put it into dbReplied -- the db output
>   ----------------------------
>   
>   -- do what you need with the datas, before parsing them back to the mc output
>   
>   -----------------------------
>   put dbReplied into Retour -- the mc output
>   
>   repeat until "<" is not in Retour -- control structure
>     put " " into char offset ("<",Retour) to offset (">",Retour) of Retour
>   end repeat
>   answer Retour -- end control structure
> end SQLbyMC
> 
> 
> on mouseUp
>   if the shiftkey is up then
>     edit script of me
>     repeat with x = 1 to the num of lines in the windows
>       if "Script Editor" is in line x of the windows then
>         set the textsize of wd line x of the windows to 12
>         set the textfont of wd line x of the windows to "Monaco"
>       end if
>     end repeat
>   else SQLbyMC
> end mouseUp


the PHP side :

> <?
> 
> if ($REQUEST_METHOD == POST) {
> 
> 	$conn = pg_connect("host=localhost port=5432 user=postgres password='' dbname=citalis");
> 	if ($conn) {
> 		
> 		$headers = $HTTP_POST_VARS;
> 		while (list($header, $value) = each($headers)) $exAE = "$header=$value";
> 		$sql = (substr($exAE,2));
> 		$result=@pg_exec($conn,$sql) or die(pg_errormessage());
> 		
> 		//ok $nor=@pg_numrows($result);
> 		//ok $nor=@pg_numfields($result);
> 		//ok $nor=@pg_cmdtuples($result);
> 		
> 		
> 		
> 		//?? $nor=@pg_lowread($result,1);
> 		//?? $nor=@pg_lowreadall($result,1);
> 		//?? $nor=@pg_fetch_row($result,1);
> 		//?? $nor=@pg_fetch_object($result,1);
> 		//?? $nor=@pg_fetch_array($result,1);
> 		//?? $nor=@pg_getlastoid($result);
> 		
> 		echo $nor;
> 		
> 		pg_close($conn);
> 		
> 		}
> }
> 
> else print("<HTML><HEAD><TITLE>ERROR: File Not Found</TITLE></HEAD>".
>         "<BODY background='/gif/fond-maison.gif'><H1>File Not Found</H1><P>".
>         "<H3>The file you have requested does not exist on this server.</H3></BODY></HTML><BR>\n");
> 
> ?>

It's not for yet a production code, just working tests. The use of PHP
to link MC and the SQL servers together is the simplest way to get good
results on the Linux plateform without having to deal with ODBC. On the
windows platform, the Rev's Tuviah SQL stack is the best starter point
to use to build a stack natively suitable with MC. The way David use to
link MySQL to MC via shell scripts is probably interessant too, even if
it's perhaps sometimes a little slower.

Regards, Pierre Sahores

WEB & VPN applications & databases servers
Inspection académique de Seine-Saint-Denis
Qualifier & produire l'avantage compétitif



More information about the metacard mailing list