Using php
david at anon.nu
david at anon.nu
Tue Sep 21 21:28:17 EDT 2004
Pierre Sahores wrote:
> Yes, it's a server side app directly speaking trought html forms on
> the client side and binded to a rock solid SQL databases server on the
> back-end. It works as a remplacement solution (and paradigm !) to the
> less stuitable Java-based stuffs built to run on top of Tomcat or
> JBoss servers.
Got the picture :)
> To have an eye on what it does (whithout writting anything in this
> real production state app, please !), you can test it on line in both
> "filling datas mode" (login : 0931213N ; password: sais0093) and
> "reporting mode" (login : synt0734 ; password: collecte) by visiting
> <http://acacia93.dyndns.org/classpac.xml>.
Thanks Pierre had a good butchers (look) as they say over here. The
basic thing I want to be clear on is what would a function in php look
like that i can call from a php scrip to set a variable? Let's take an
example. Below is a php script for getting data from a mysql database
and setting some variables for use in a smarty template, the key bit is
not really the database stuff which is what we would replace by calling
Rev to act as middle ware, but the php function that could be written to
talk to the socket listening Rev app and get the results back so as to
set a variable in php (ie the $smarty->assign("url",$url); bit). I am
thinking that we could have one generic php function that takes the name
of a Rev based object to call and maybe some params, passes the usual
post day suitable packaged, and then returns data (maybe as an array)?
<?
/*
PHP script, sends mysql result to a Smarty template
*/
require_once("Smarty.class.php");
$smarty = new Smarty;
// connect db
mysql_connect('localhost', 'test', 'test');
mysql_select_db('test');
$query = "select link, descr, DATE_FORMAT(date_added, '%e %M %Y') as date, name from intranet_links";
// search for $s
if ($s)
$query .= " where (descr like '%$s%' or link like '%$s%')";
$result = mysql_query($query);
while ($data = mysql_fetch_array ($result))
{
$url[] .= $data[link];
$descr[] .= $data[descr];
$name[] .= $data[name];
$date[] .= $data[date];
}
$smarty->assign("url",$url);
$smarty->assign("descr",$descr);
$smarty->assign("name",$name);
$smarty->assign("date",$date);
$smarty->display("mysql.tpl");
// close db
mysql_close();
?>
More information about the metacard
mailing list