ADS & PHP

ADS & PHP

Postby cdmmaui » Tue Sep 09, 2008 4:18 am

Hello,

Is it possible to connect to an ADS DBFCDX database via PHP? If so, does anyone have sample code they can provide?
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

hi

Postby lailton.webmaster » Thu Sep 11, 2008 9:49 am

hey there friend

i work with PHP long time and php no is compatible with dbfcdx
u can use mysql or sqlite

i recoment mysql is more speed and easy to use
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

dbfcdx

Postby lailton.webmaster » Thu Sep 11, 2008 9:51 am

other alterenative is u use wepwap that u make urweb with how u make
progman with xharbour, in the really is a xharbour that u make a file page.exe "CGI" that make connection with dbf

thanks ;)
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Postby zazibr » Thu Sep 11, 2008 11:45 am

Daniel Lopes Filho - Campo Grande,MS,Brasil
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6693) + gtwvw + fw 10.2 + vsx e
fw pcc (ainda não usei)
msn : zazibr@hotmail.com
zazibr
 
Posts: 71
Joined: Mon Jan 28, 2008 11:18 am
Location: Campo Grande,MS, BRASIL

Postby reinaldocrespo » Wed Sep 24, 2008 4:35 pm

This is a late answer, but I just read the post. Yes you can read dbf/cdx, adt/adi, and dbf/ntx with PHP + ADS. But you must be using ADS Data Dictionaries and all data access must be using SQL statements.

Here are some PHP sample code working with DBF/CDX and DBF/NTXs. First how to connect to the data dictionary and appending some info to log.dbf table:
Code: Select all  Expand view
//sample appending records to a dbf/ntx table:

      if ( !DDconnect( _DATA_DICT, $rConn ) ) die( "<br> Error connecting to Database.<br>" ) ;
      $rStmt = ads_prepare( $rConn, "INSERT INTO log ( [UserId], [login_date], [ip] ) VALUES( ?, now(), ? )" );
      $aParms = array( 1 => $user, 2 => $_SERVER[ 'REMOTE_HOST' ].$_SERVER[ 'REMOTE_ADDR' ] );
      $rResult = ads_execute( $rStmt, $aParms );
         
      ads_close( $rConn );

//----------------------------------------------------------------------------------------------------------------------
function DDconnect( $db, &$rConn ) {
   
   $user = $_SESSION[ 'userid' ];
   $pass = $_SESSION[ 'password' ];

   $rConn   = ads_connect( $db, $user, $pass, SQL_CURSOR_DYNAMIC );

   return is_resource( $rConn );
}



Trying to keep it simple, below is code for updating cases.dbf/cdx table:
Code: Select all  Expand view
         $aParms= array( 1 => "[Save Command]:<".date("M-d-y h:m:sa").">\n".$_POST[ 'solution' ],
                     2 => $user,
                     3 => $_POST[ 'status' ] == "Open" ? FALSE :TRUE ,
                     4 => $case,
                     5 => $isTech );
                     
         $query = "UPDATE cases SET [Solution] = ?, [Solution_date] = now(),
                     [Tech] = ?, [Status] = ? WHERE [Case_no] = ? AND ? = TRUE" ;
         $rStmt = ads_prepare( $rConn, $query );
         $rResult = ads_execute( $rStmt, $aparms ) ;



Finally some code quering ticket_feedback.adt:
Code: Select all  Expand view
         $query = "SELECT [comments], [time_stamp], [sequence] FROM ticket_feedback ".
               "WHERE Case_no = ? ORDER BY [sequence]" ;
         $rStmt = ads_prepare( $rConn, $query );
         $aparms = array( 1 => $_GET[ 'case' ] );
         $rResult = ads_execute( $rStmt, $aparms ) ;


I hope this clarifies that indeed you can use dbf-cdx/ntx/adt-adi with PHP. Might I add; IT WORKS GREAT! All this data is maintain from a fwh win32 application. The PHP web app is mostly used for quering from remote locations. It is easy, it is fast, and it is save. But, you must be using ADS data dictionaries... (also simple).


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests