-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.php
More file actions
84 lines (69 loc) · 1.86 KB
/
Copy pathdb.php
File metadata and controls
84 lines (69 loc) · 1.86 KB
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
<?php
include ('/var/local/brisskit/drupal/site/civicrm/sites/default/civicrm.settings.php');
require_once ('/var/local/brisskit/drupal/site/civicrm/sites/all/modules/civicrm/packages/DB.php');
function get_component_id_by_case_id ($case_id) {
print "case_id = $case_id\n";
$db = DB::connect(CIVICRM_DSN);
if (PEAR::isError($db)) {
die($db->getMessage());
}
$sth = $db->prepare('SELECT component_id FROM brisskit_case_mappings where case_id = ?');
$res =& $db->execute($sth, $case_id);
if (PEAR::isError($res)) {
die($res->getMessage());
}
if ($row =& $res->fetchRow()) {
return $row[0];
}
else {
return 0;
}
$db->close();
}
function get_component_name_by_id ($component_id) {
print "component_id = $component_id\n";
$db = DB::connect(CIVICRM_DSN);
if (PEAR::isError($db)) {
die($db->getMessage());
}
$sth = $db->prepare('SELECT component_name FROM brisskit_components where component_id = ?');
$res =& $db->execute($sth, $component_id);
if (PEAR::isError($res)) {
print_r($res);
die($res->getMessage());
}
if ($row =& $res->fetchRow()) {
return $row[0];
}
else {
return '';
}
$db->close();
}
function get_component_id_by_name ($name) {
print "case_id = $case_id\n";
$db = DB::connect(CIVICRM_DSN);
if (PEAR::isError($db)) {
die($db->getMessage());
}
$sth = $db->prepare('SELECT component_id FROM brisskit_components where component_name = ?');
$res =& $db->execute($sth, $name);
if (PEAR::isError($res)) {
die($res->getMessage());
}
if ($row =& $res->fetchRow()) {
return $row[0];
}
else {
return 0;
}
$db->close();
}
$comp_id = get_component_id_by_case_id (33);
print "$comp_id \n";
$comp_name = get_component_name_by_id ($comp_id);
print "$comp_name \n";
$comp_id = get_component_id_by_name ('recruitment');
print "$comp_id \n";
exit;
?>