HOME – Download code
2.Sept.2015 I uploaded ng_understand.rar – it contains now all CRUD code.
It seems to me that ng is very nice but brings no advantage – PHP is enough, and problem is to learn two programming techniques, to include ng (minimum 150 kB) …
We fill in $scope ng object with Oracle DB 11g data with help of
AJAX “client-server” PHP script get_emp_data.php (hr user).
Output page shows (looks better with .css included in zip):
AngularJS (ng) ver. 1.4.3
ng & PHP server script Get Emp from oracle DB 11g
Search:
EmpId | LastName | HireDate |
---|---|---|
DML: | select EMPLOYEE_ID, LAST_NAME, HIRE_DATE from (select EMPLOYEE_ID, LAST_NAME,to_char(HIRE_DATE,’RRRR.DD.MM’) HIRE_DATE from EMPLOYEES order by LAST_NAME) where ROWNUM < 11 | |
167 | Banda | 2008.21.04 |
116 | Baida | 2005.24.12 |
This script get_emp.html 15.7.2015 says:
- Script get_emp.html is same as index.html – understand ng.
Included is app.js code for quick testing.
Added are few additional lines to fill in $scope object from Oracle DB 11g data with help of
AJAX “client-server” called PHP script get_emp_data.php. - Search field works after every character typed in.
- Click on eg HireDate column title works but not for both sorts asc/desc – I shall do this later.
- I shall add later to this post (to ng_understand.zip)
all CRUD functions in programming techniques :
ng – PHP server scripts called with AJAX (client-server web programming technique) – Oracle DB 11g.// get_emp.html contains app.js code for quick testing // HH24:mi:ss $http.get("get_emp_data.php?sqlStr=" +"select EMPLOYEE_ID, LAST_NAME, HIRE_DATE from" +" (select EMPLOYEE_ID, LAST_NAME" + ",to_char(HIRE_DATE,'RRRR.DD.MM') HIRE_DATE + " from EMPLOYEES order by LAST_NAME)" +" where ROWNUM < 11" ) .success( function(response) { $scope.myData = response; $scope.reverse = true; } ) .error( function() { } ) ;
- AJAX “client-server” called PHP script get_emp_data.php has ~five important statements:
<?php /* http://dev1:8083/my_dev/test/...get_emp_data.php http://dev1:8083/my_dev/test/...get_emp_data.php?sqlStr=select... J:\awww\apl\dev1\my_dev\test\...get_emp_data.php */ $pdo=new PDO('oci:dbname=sspc/XE','hr','hr'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare($_GET['sqlStr']); /* $stmt = $pdo->prepare( 'select EMPLOYEE_ID, LAST_NAME' .',to_char(HIRE_DATE,\'DD.MM.RRRR\') HIRE_DATE' // HH24:mi:ss .' from EMPLOYEES where ROWNUM < 16' ); */ $stmt->execute(); $arr = array(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $arr[] = $row; } //echo '<pre>'; print_r($arr); echo '</pre>'; //$arr = $_GET; // {"sqlStr":"select..."} $arr[] = Array ( 'EMPLOYEE_ID' => "DML:" ,'LAST_NAME' => $_GET['sqlStr'] ,'HIRE_DATE' => '' ); //{"EMPLOYEE_ID":"114","LAST_NAME":"Raphaely","HIRE_DATE":"07.12.2002"}, //{"EMPLOYEE_ID":-1,"LAST_NAME":"select...","HIRE_DATE":""}] $json_response = json_encode($arr); echo $json_response; ?>