8\. Understand AngularJS (ng) ver. 1.4.3 & PHP server script Get Emp from Oracle DB 11g
=======================================================================================
**[HOME](http://phporacle.altervista.org/php-oracle-main-menu/ "Main menu")** ? 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
[Main page](http://dev1:8083/)
* [Home](http://dev1:8083/my_dev/test/books/00_angularjs_demosWahlin/understand_ngjs/get_emp.html#)
* [Directive](http://dev1:8083/my_dev/test/books/00_angularjs_demosWahlin/understand_ngjs/directives.html)
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:
1. 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**.
2. Search field works after every character typed in.
3. Click on eg HireDate column title works but not for both sorts asc/desc ? I shall do this later.
4. 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() {
}
) ;
5. 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.phpsqlStr=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;**
>
kod[ edit]($web_docroot_url/inc/utl/edservertxt.php)[ phpinfo]($web_docroot_url/phpinfo_inc.php) EOKOD; /\* call it so: kod\_edit\_run( $idx // script\_dir\_path , $idxscript // script\_name , MDURL); // web\_docroot\_url = (Apache) web server URL \*/ }
|