Example #1
0
 public function getQuery(Database $databaseConnection)
 {
     if (count($this->_fields) == 0) {
         return '';
     }
     $q = 'UPDATE ' . $this->table . ' SET ';
     $first = true;
     $data = array();
     foreach ($this->_fields as $field) {
         if ($first) {
             $first = false;
         } else {
             $q .= ',';
         }
         $q .= $field[0] . '=' . $field[2];
         $data[] = $field[1];
     }
     $q .= ' WHERE ' . $this->_where[0];
     $data[] = $this->_where[1];
     return $databaseConnection->prepareQuery($q, $data);
 }
Example #2
0
 public function getQuery(Database $databaseConnection)
 {
     if (count($this->fields) == 0) {
         return '';
     }
     $q = 'INSERT INTO ' . $this->table;
     $fields = '';
     $values = '';
     $data = array();
     $first = true;
     foreach ($this->fields as $field) {
         if ($first) {
             $first = false;
         } else {
             $fields .= ',';
             $values .= ',';
         }
         $fields .= $field[0];
         $values .= $field[2];
         $data[] = $field[1];
     }
     return $databaseConnection->prepareQuery($q . '(' . $fields . ')VALUES(' . $values . ')', $data);
 }
$currentHTTP = "http://data-archive.library.ucla.edu/da_catalog/";
//SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
include "../_includes/SSDA_librarydatabase.php";
//SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
// class for database connections
include "../_classes/class.Database.php";
$query = "select title.StudyNum, title.Title FROM title where title.Restricted <> '*' ORDER BY title.StudyNum";
// sql query statement
// NOTE: original query did not exclude the Restricted items
// $query = "select title.Title, title.StudyNum, shfull.subject, Left(shfull.subject,1) AS firstLetterIndex, count(*) as titlePerSubjectCount FROM (title INNER JOIN shcode ON title.tisort = shcode.tisort) INNER JOIN shfull ON shcode.subjectcode = shfull.subjectcode group by shfull.subject ORDER BY shfull.subject";
// echo "<br>$query<br>";
// class.Database.php  is the class to make PDO connections
// initialize new db connection instance
$db = new Database();
// prepare query
$db->prepareQuery($query);
// execute query
$result = $db->executeQuery();
//$result = $db->resultset();  // execute the query
if (!$result) {
    die("Could not query the database: <br />");
}
// else {  echo "Successfully queried the database.<br>";   }  // for debugging
// the index term list
$studynumberList = array();
echo "<form action='da_catalog_titleRecord.php' method='put' name='studynumber' target='_self'>";
echo "<select name='studynumber' class='alphaTitleList'>";
$row_index = 0;
while ($row = $db->getRow()) {
    $title = $row['Title'];
    $tempStudynumber = $row['StudyNum'];
Example #4
0
 public function delete()
 {
     $db = new Database();
     $sql = "DELETE FROM locations WHERE id=?";
     $sql = $db->prepareQuery($sql, $this->id);
     $db->query($sql);
 }
Example #5
0
function updatePersonKind($id, $personKind)
{
    $db = new Database();
    $sql = "UPDATE personKinds SET personKind=? WHERE id=?";
    $sql = $db->prepareQuery($sql, $personKind, $id);
    $db->query($sql);
    return array('id' => $id, 'personKind' => $personKind);
}
include "../_includes/SSDA_librarydatabase.php";
//SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
// class for database connections
include "../_classes/class.Database.php";
$searchTerm = htmlspecialchars($_GET['searchTerm'], ENT_QUOTES);
// check, if NOT set
if (empty($searchTerm)) {
    echo "<span style='margin-left: 0; text-align: center; background-color: powderblue;'>\n\t\t<a href='da_catalog_titles.php'>Return to catalog.</a></span><br>";
    die("Nothing selected.");
}
$query_searchStuff = "select distinct StudyNum, Title from (SELECT title.Title, title.Restricted, title.StudyNum, pifull.pi, shfull.subject, shfull.icpsrcountry FROM (((title LEFT JOIN picode ON title.tisort = picode.tisort) LEFT JOIN pifull ON picode.picode = pifull.picode) LEFT JOIN shcode ON title.tisort = shcode.tisort) LEFT JOIN shfull ON shcode.subjectcode = shfull.subjectcode) as searchStuff where ((Title like '%" . $searchTerm . "%') or (StudyNum like '%" . $searchTerm . "%') or (pi like '%" . $searchTerm . "%') or (subject like '%" . $searchTerm . "%') or (icpsrcountry like '%" . $searchTerm . "%'))and (Restricted <> '*')  order by Title";
// class.Database.php  is the class to make PDO connections
// initialize new db connection instance
$db = new Database();
// prepare query
$db->prepareQuery($query_searchStuff);
// bind value studynumber
$db->bind(":searchTerm", $searchTerm);
// execute query
$result = $db->executeQuery();
//$result = $db->resultset();  // execute the query
if (!$result) {
    die("Could not query the database: <br />");
}
// else {  echo "Successfully queried the database.<br>";   }  // for debugging
echo "<H2>Results of Search in Data Archives Studies</H2>";
echo "Search term(s)<strong> " . $searchTerm . "</strong>";
echo "<ul>";
$row_index = 0;
while ($row = $db->getRow()) {
    $title = $row["Title"];
//echo $studynumber . "<br>";
$queryBaseRecord = "SELECT title.*, picode.picode, picode.tisubsort, pifull.*, shcode.subjectcode, shfull.*, title.StudyNum, wwwlink_pi.wwwlink AS wwwlink_pi, wwwlink_pi.wwwtext AS wwwtext_pi, wwwlink_subject.wwwlink AS wwwlink_subject, wwwlink_subject.wwwtext AS wwwtext_subject, cite.cite, pifull.picode, shcode.subsort, picode.tisubsort FROM cite RIGHT JOIN ((((((title LEFT JOIN picode ON title.tisort = picode.tisort) LEFT JOIN pifull ON picode.picode = pifull.picode) LEFT JOIN shcode ON title.tisort = shcode.tisort) LEFT JOIN shfull ON shcode.subjectcode = shfull.subjectcode) LEFT JOIN wwwlink AS wwwlink_subject ON shfull.subjectcode = wwwlink_subject.subjectcode) LEFT JOIN wwwlink AS wwwlink_pi ON pifull.picode = wwwlink_pi.picode) ON cite.citenum = title.Cite WHERE title.StudyNum='" . $studynumber . "'";
$queryDatasetRecords = "SELECT wwwlink.wwwlink, wwwlink.wwwtext, wwwlink.studynum, fileinfo.*, data_cite.cite AS datacite, fileinfo.Restricted AS restricted_file, fileinfo.StudyNum FROM cite AS data_cite RIGHT JOIN (wwwlink RIGHT JOIN fileinfo ON wwwlink.dtafile = fileinfo.DTAfile) ON data_cite.citenum = fileinfo.Cite WHERE fileinfo.StudyNum='" . $studynumber . "' AND (FileType = 'CD-Rom' OR FileType = 'SDA Online Analysis' OR FileType = 'Web Access') ORDER BY fileinfo.StudyPart";
//echo $queryDatasetRecords . "<br>";
// check, if NOT set
if (empty($studynumber)) {
    //   remove $title test, this will eventually be phased out as redundent -  or !isset($_GET['title'])  - jmj120409
    echo "<span style='margin-left: 0; text-align: center; background-color: powderblue;'><a href='da_catalog_titles.php'>Return to catalog.</a></span><br>";
    die("Nothing selected.");
}
//echo $title<br>$studynumber<br>";
// class.Database.php  is the class to make PDO connections
// initialize new db connection instance
$db = new Database();
// prepare query
$db->prepareQuery($queryBaseRecord);
// bind value studynumber
$db->bind(":studynumber", $studynumber);
// PDO - execute the query
$result = $db->executeQuery();
//$result = $db->resultset();  // execute the query
if (!$result) {
    die("Could not query the database: <br />");
}
// else {  echo "Successfully queried the database.<br>";   }  // for debugging
//echo "<H2>$title&nbsp;&nbsp;($studynumber)</H2><br>";
// complete record info
$titleRecord = array();
// record - the title, sub# and restricted y/n
// list of pi(s)
$piList = array();