FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADS & PHP
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
ADS & PHP
Posted: Tue Sep 09, 2008 04: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
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
hi
Posted: Thu Sep 11, 2008 09: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

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
dbfcdx
Posted: Thu Sep 11, 2008 09: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 ;)

Posts: 71
Joined: Mon Jan 28, 2008 11:18 AM
ADS & PHP
Posted: 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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
ADS & PHP
Posted: Wed Sep 24, 2008 04: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:
//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:
			$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:
			$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.

Continue the discussion