PHP and Oracle database

Discuss other programming languages besides AutoHotkey
ureccnewbie
Posts: 1
Joined: 27 Nov 2018, 17:03

PHP and Oracle database

29 Nov 2018, 15:42

I am using AutoHotkey with PHP to display information from an Oracle database to the screen in a SAS environment. My problem is that when I modify the SQL in the PHP code, my labels on the screen are good but the data retrieved is not displaying.The AutoHotkey code is as follows:

Code: Select all

==============================================================
^!g::
;Get title where SO is stored
WinGetTitle,Title,Comments - SO

;Strip all but SO #
StringTrimLeft,SONum,Title,15

;Download to temp file
UrlDownloadToFile,http://10.46.30.43/connInfo/search/%SONum%,%A_AppData%\temp.txt

;Read file contents into clipboard and paste
FileRead, Contents, %A_AppData%\temp.txt
if not ErrorLevel  ; Successfully loaded.
{
	clipboard = %Contents%
	Send ^v
}
return
=========================================================

The PHP script to connect and run the SQL is as follows:

	public function getDeviceInfo($strBiSrvLocNbr)
	{
		if (empty($strBiSrvLocNbr)) throw new Exception(__CLASS__.'->'.__FUNCTION__.'['.__LINE__.']: Service Location Number cannot be NULL');

		$strSQL = sprintf
		(
			'SELECT
				BIDTGR.BI_DVC_TYPE_GRP_DESC
				,BIDS.BI_DVC_TYPE
				,BIDR.BI_DVC_DESC
				,BIDI.BI_DVC_STAT_CD
				,BIDS.BI_X_COORD
				,BIDS.BI_Y_COORD
			FROM
				BI_DVC_SRV BIDS
				INNER JOIN
				BI_DVC_INV BIDI ON BIDS.BI_DVC_SER_NBR = BIDI.BI_DVC_SER_NBR
				INNER JOIN
				BI_DVC_REF BIDR ON BIDI.BI_DVC_TYPE = BIDR.BI_DVC_TYPE
				INNER JOIN
				BI_DVC_TYPE_GRP_REF BIDTGR ON BIDR.BI_DVC_TYPE_GRP = BIDTGR.BI_DVC_TYPE_GRP
			WHERE
				BIDS.BI_SRV_LOC_NBR=\'%s\'
			ORDER BY
				BIDS.BI_DVC_TYPE DESC'
			,Janitor::sanitizeString($strBiSrvLocNbr)
		);

		try 
		{
			$stmt = $this->_objDatabase->query($strSQL);
			
			if ($stmt === FALSE) return false;

			$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
			return $results;
			
		} 
		catch (Exception $e) 
		{
			throw new Exception(__CLASS__.'->'.__FUNCTION__.' [' . __LINE__ . ']: Unable to get device information.', 0, $e);
		}
	}

The PHP that displays to the screen is as follows:

foreach ($aryDeviceInfo as $device)
{
    $strBiDvcTypeGrpDesc    = (!empty($device['BI_DVC_TYPE_GRP_DESC'])) ? $device['BI_DVC_TYPE_GRP_DESC'] : '';
    $strBiDvcType           = (!empty($device['BI_DVC_TYPE'])) ? $device['BI_DVC_TYPE'] : '';
    $strBiDvcDesc           = (!empty($device['BI_DVC_DESC'])) ? $device['BI_DVC_DESC'] : '';
    $strBiDvcStatCd         = (!empty($device['BI_DVC_STAT_CD'])) ? $device['BI_DVC_STAT_CD'] : '';
    $strBiDvcXCoord         = (!empty($device['BI_DVC_X_COORD'])) ? $device['BI_DVC_X_COORD'] : '';
    $strBiDvcYCoord         = (!empty($device['BI_DVC_Y_COORD'])) ? $device['BI_DVC_Y_COORD'] : '';

	$strDeviceInformation .= sprintf
	(
		"Device Group: %s".PHP_EOL.
		"Device Type: %s".PHP_EOL.
		"Device Description: %s".PHP_EOL.
		"Status: %s".PHP_EOL.
		"X Coord: %s".PHP_EOL.
		"Y Coord: %s".PHP_EOL,
		$strBiDvcTypeGrpDesc,
		$strBiDvcType,
		$strBiDvcDesc,
		$strBiDvcStatCd,
		$strBiDvcXCoord,
		$strBiDvcYCoord
	);

Screen print:
==============================================
Device Info:
--------------------
Device Group: LED Lighting
Device Type: L50
Device Description: LED Outdoor Light 50W
Status: 1
X Coord: 
Y Coord: 
Srv Loc Nbr: 
============================================
Any ideas or suggestions are much appreciated.

Moderator Note: Added code tags. ~sinkfaze
gregster
Posts: 3275
Joined: 30 Sep 2013, 06:48

Re: PHP and Oracle database

29 Nov 2018, 18:56

I don't have your setup, but I already don't know what this means: "my labels on the screen are good but the data retrieved is not displaying".
Is there something in the temp.txt file or not? If not, what is the connection to AutoHotkey? (The AHK part seems rather small)
Is it rather a PHP/SQL problem?
joya10
Posts: 1
Joined: 11 Mar 2019, 14:01

Re: PHP and Oracle database

11 Mar 2019, 14:02

PHP is a popular web scripting language, and is often used to create database-driven web sites. This tutorial helps you get started with PHP and Oracle Database by showing how to build a web application and by giving techniques for using PHP with Oracle. If you are new to PHP, review the Appendix: PHP Primer to gain an understanding of the PHP language.

Prerequisites
Before starting this Oracle By Example, please have the following prerequisites completed:

1 .

Install Oracle Database 11.2

2 .

Start DRCP connection pooling:

sqlplus / as sysdba
execute dbms_connection_pool.start_pool();
execute dbms_connection_pool.restore_defaults();
3 .

Create a user named PHPHOL with password of 'welcome'. Install Oracle's sample
HR schema and make the following changes:

create sequence emp_id_seq start with 400;
create trigger my_emp_id_trigger
before insert on employees for each row
begin
select emp_id_seq.nextval into :new.employee_id from dual;
end;
/
--
-- Also to simplify the example we remove this trigger otherwise
-- records can only be updated once without violating the
-- PYTHONHOL.JHIST_EMP_ID_ST_DATE_PK constraint
--

drop trigger update_job_history;

--
-- Allow employees to be changed when testing the lab after hours.
--
drop trigger secure_employees;
4 .

Install Apache and enable UserDir module for public_html

5 .

Install PHP 5.3.3 with the OCI8 1.4 extension. In php.ini set:

oci8.connection_class = MYPHPAPP
6 .

Extract these files to your $HOME location.
User avatar
tank
Posts: 2757
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: PHP and Oracle database

11 Mar 2019, 14:10

I have moved this topic to other programming languages since it appears to be a PHP question
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 1 guest