Hi Tuviah,

Sorry for the "so late" answer...  i was in holidays for the two last
weeks.

> >That's are great good news ! Don't forget, anyway, that it's still a
> second way
> >to connect odbc-sources from within mc in using PHP. This works on both
> Unixes
> >and Win32 systems (see previous mails on the list archive).
> Cool! I'm working on porting the ODBC external to Linux, and since it'll
> be open sourced developers will be able to compile it wherever they like.
> I've looked at some of the linux/odbc sites and am confident that since I
> used source based upon the php/perl/and microsoft odbc code that porting
> the external should be very straightforward. However I have no experiance
> with installing ODBC and the drivers under Unix, and am hoping you can
> give me some tips/instructions on which driver manager to install(I see
> IODBC and UnixODBC as the only options), where to locate the drivers and
> databases, 

To put in your mc script :
  # set httpHeaders to "Content-Type: text/html" & cr &
"Content-Length:" && the length of postSQL & cr & cr # Apache : needed ;
IIS4 : unneeded
  # as far as i know, Metacard 2.32 is unable to handle cleanly "POST"
requests...
  # put ("http://localhost/cndp/repmssqlo.php?"; & PostIn) into tempo #
first "GET" request form, usable from within Metacard 2.32
  put url "http://localhost/cndp/repmssql.php"; into tempo # second "GET"
request form, usable from within Metacard 2.32
  # set httpHeaders to "" # Apache : needed ; IIS : unneeded

The "repmssql.php" script :
  <?
set_time_limit ("0");
$connection = odbc_connect('BNPRsimbad','snpin','okapi');

$query = 'select
artitre,stitre,resume_ed,lieu,editeur,annee_ed,description,isbn,id_produit,fk_id_type_collection,fk_id_collection
 
          from t_produit_view B where ((B.fk_id_classement=1) or
(B.fk_id_classement=2)) order by id_produit';

$result = odbc_do($connection, $query);

$retour = '';
//$couunter = '0';

while(odbc_fetch_row($result)) {

        //$counter++;

        $artitre = odbc_result($result,1);
        $stitre = odbc_result($result,2);
        $resume_ed = odbc_result($result,3);
        $lieu = odbc_result($result,4);
        $editeur = odbc_result($result,5);
        $annee_ed = odbc_result($result,6);
        $description = odbc_result($result,7);
        $isbn = odbc_result($result,8);
        $id_produit = odbc_result($result,9);
        $fk_id_type_collection = odbc_result($result,10);
        $fk_id_collection = odbc_result($result,11);

        $retour1 = ('artitre : '.$artitre.' �stitre : '.$stitre.'<rl><rl>
�resume_ed : '.
        $resume_ed.' �lieu : '.$lieu.' editeur : '.$editeur.' ann�e_ed :
'.$annee_ed.
        ' �description : '.$description.' isbn : '.$isbn);

        $retour3 = (' �id_produit : '.$id_produit.
        ' �fk_id_type_collection : '.$fk_id_type_collection.
        ' �fk_id_collection : '.$fk_id_collection);

        $retour4 = (' editeur : '.$editeur);

        $query2 = 'select code_reference,prix_courant from t_reference_view A
                   where (A.fk_id_produit='.$id_produit.')';
        
        $result2 = odbc_do($connection, $query2);
        
        while(odbc_fetch_row($result2)) {
                $code_reference = odbc_result($result2,1);
                $prix_courant = odbc_result($result2,2);
                
                $retour = $retour1.(' �code_reference R&#233;f : '.$code_reference.
                ' � prix_courant Prix : '.$prix_courant.'F').$retour3;
        }

        if ($fk_id_type_collection != '0') {
        
                if ($fk_id_type_collection == '1') 
                        $query2 = 'select lib_collection 
                        from lst_collection_nat 
                        where (id_collection='.$fk_id_collection.')';
                else $query2 = 'select lib_collection 
                        from lst_collection_acad where
(id_collection='.$fk_id_collection.')';         
        
                $result2 = odbc_do($connection, $query2);
        
                while(odbc_fetch_row($result2)) {

                        $lib_collection = odbc_result($result2,1);
                        $retour = $retour.(' �lib_collection : '.$lib_collection);
                }
        }
        
        $query2 = 'select distinct lib_support
        from
        (t_documentaire_view inner join lst_support on
t_documentaire_view.fk_id_support_doc=lst_support.id_support) 
        where (t_documentaire_view.fk_id_produit='.$id_produit.')';
                  
        $result2 = odbc_do($connection, $query2);
        
        while(odbc_fetch_row($result2)) {
                
                $lib_support = odbc_result($result2,1);
                $retour = $retour.(' �lib_support : '.$lib_support);
        }
        
        $query2 = 'select la_discipline 
                        from (t_lien_discipline_view D inner join lst_discipline E on
                        D.fk_id_discipline=E.id_discipline) where
D.sk_id_produit='.$id_produit;
                        $result2 = odbc_do($connection, $query2);
        
        while(odbc_fetch_row($result2)) {

                $la_discipline = odbc_result($result2,1);
                $retour = $retour.(' �la_discipline : '.$la_discipline);
        }
        
        $query2 = 'select le_niveau from 
        (t_lien_niveau_view D inner join lst_niveau E on
D.fk_id_niveau=E.id_niveau) 
        where D.sk_id_produit='.$id_produit;

        $result2 = odbc_do($connection, $query2);
        
        while(odbc_fetch_row($result2)) {

                $le_niveau = odbc_result($result2,1);
                $retour = $retour.(' �le_niveau : '.$le_niveau);
        }                  
        
        $query2 = 'select distinct code_dewey 
        from (t_documentaire_view inner join t_dewey_view 
        on t_documentaire_view.id_documentaire=t_dewey_view.fk_id_documentaire) 
        where t_documentaire_view.fk_id_produit='.$id_produit;
                  
        $result2 = odbc_do($connection, $query2);
        
        while(odbc_fetch_row($result2)) {
                
                $code_dewey = odbc_result($result2,1);
                $retour = $retour.(' �code_dewey : '.$code_dewey);              
        }
        
        $query2 = 'select distinct lib_mots_cles from 
        (t_lien_mots_cles_view L inner join lst_mots_cles M 
        on (L.fk_id_mots_cles=M.id_mots_cles)) 
        where (L.sk_id_produit='.$id_produit.')';
                  
        $result2 = odbc_do($connection, $query2);
        
        while(odbc_fetch_row($result2)) {
                
                $lib_mots_cles = odbc_result($result2,1);
                $retour = $retour.(' �lib_mots_cles : '.$lib_mots_cles);
        }

$retour = $retour.$retour4;

print($retour.'<br>');
$retour = '';

}

odbc_close($connection);
?>

As you can see, i just use the Metacard ability to catch url contents...
parsed by a tree-party interpreter (PHP 3, ASP, Perl, Python, etc... are
usable there). If i chose PHP, even to run it on WinNT boxes, it's
because its speed behind ASP ; i did'nt test the others interpreters).
The above scripts have run six months without trubble, betwin two WinNT4
servers, one for the httpd/mc-based was server, the second for the
microsoft sql
server 6.5 database server.

The same kind of config is usable to link any kind of httpd/was server
(even MacOS9) to any kind of sql database server (Unixes prefered). On
Unixes boxes, including Linux, both the two servers sides can be
installed on the same G4/P4 computer without any trubble if you don't
need to serve more than 500 requests peer second.

> and also if you would be kind enough to test it(before
> released) with a few of your own data sources.

With pleasure if that can help !

> Tuviah

Kind Regards and sorry again for the so late answer... Pierre Sahores
--
WEB & VPN applications & databases servers
Inspection acad�mique de Seine-Saint-Denis
Qualifier & produire l'avantage comp�titif

Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to