forked from DanieDuToit/BusinessEntity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionTests.php
101 lines (90 loc) · 3.53 KB
/
FunctionTests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Created by PhpStorm.
* User: dutoitd1
* Date: 2014/10/08
* Time: 1:29 PM
*/
$path = explode(DIRECTORY_SEPARATOR, __FILE__);
include_once "IncludesAndClasses/DBBase.class.php";
include_once @"IncludesAndClasses/BranchBase.class.php";
include_once "IncludesAndClasses/functions.inc.php";
$dbBaseClass = new DBBase();
$BranchBase = new BranchBase();
$BranchRecord = $BranchBase::$Branch;
$name = $BranchRecord['BranchCode']['FieldName'];
$help = $BranchRecord['BranchCode']['Helptext'];
initializeFieldParametersArray($fieldParams);
$t = array_key_exists(FieldParameters::class_par, $BranchRecord['BranchCode'][0]);
$v1 = $BranchRecord['BranchCode'][0][FieldParameters::class_par];
$t = array_key_exists(FieldParameters::groupIdName_par, $BranchRecord['BranchCode'][0]);
$t = array_key_exists(FieldParameters::autoRefresh_par, $BranchRecord['BranchCode'][0]);
$BranchRecord['BranchCode']['Value'] = "Branch'Code";
$BranchRecord['Name']['Value'] = "Names's";
$BranchRecord['Active']['Value'] = '0';
$BranchRecord['ContactPersonName']['Value'] = 'ContactPersonName';
$BranchRecord['PhoneNumber']['Value'] = '(012)2311234';
$BranchRecord['FaxNumber']['Value'] = '(012)2311234';
$BranchRecord['Longitude']['Value'] = '123.4567';
$BranchRecord['Latitude']['Value'] = '123.4567';
$BranchBase->update('Branch', 'id', 1, $BranchRecord);
if ($dbBaseClass->conn) {
echo "Connection established.<br />";
} else {
echo "Connection could not be established.<br />";
die(dbGetErrorMsg());
}
// Using dbQuery
echo '<h2>Using dbQuery</h2>';
$sql = "SELECT TOP(10) Name FROM company";
$stmt = $dbBaseClass->dbQuery($sql);
if ($stmt === false) {
die(dbGetErrorMsg());
}
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
echo $row['Name'] . ", " . "<br />";
}
sqlsrv_free_stmt($stmt);
// Using getAll
echo '<h2>Using getAll</h2>';
$stmt = $dbBaseClass->getAll('Company');
if ($stmt === false) {
die(dbGetErrorMsg());
}
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
echo $row['Name'] . ", " . "<br />";
}
sqlsrv_free_stmt($stmt);
// Using getAllByFieldname
echo '<h2>Using getAllByFieldname</h2>';
$stmt = $dbBaseClass->getAllByFieldName('Company', 'Name', 'Protea Security');
if ($stmt === false) {
die(dbGetErrorMsg());
}
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
echo $row['Name'] . ", " . "<br />";
}
sqlsrv_free_stmt($stmt);
// Using getFieldsByFieldname
echo '<h2>Using getFieldsByFieldname</h2>';
$fields = array('Name', 'CompanyCode');
$stmt = $dbBaseClass->getFieldsByFieldName('Company', 'Name', 'Protea Security', $fields);
if ($stmt === false) {
die(dbGetErrorMsg());
}
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
echo "{$row['Name']} , {$row['CompanyCode']} <br />";
}
sqlsrv_free_stmt($stmt);
// Using getFieldsForAll
echo '<h2>Using getFieldsForAll</h2>';
$fields = array('Name', 'CompanyCode');
$stmt = $dbBaseClass->getFieldsForAll('Company', $fields);
if ($stmt === false) {
die(dbGetErrorMsg());
}
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
echo "{$row['Name']} , {$row['CompanyCode']} <br />";
}
sqlsrv_free_stmt($stmt);
?>