本文整理汇总了PHP中pdo_error函数的典型用法代码示例。如果您正苦于以下问题:PHP pdo_error函数的具体用法?PHP pdo_error怎么用?PHP pdo_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdo_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CoveragePerDirectory
/** Return the coverage per directory with the number of lines
* covered and not covered */
private function CoveragePerDirectory()
{
include_once '../cdash/common.php';
if (!isset($this->Parameters['project'])) {
echo "Project not set";
return;
}
$projectid = get_project_id($this->Parameters['project']);
if (!is_numeric($projectid) || $projectid <= 0) {
echo "Project not found";
return;
}
// Select the last build that has coverage from the project
$query = pdo_query("SELECT buildid FROM coveragesummary,build WHERE build.id=coveragesummary.buildid\n AND build.projectid='{$projectid}' ORDER BY buildid DESC LIMIT 1");
echo pdo_error();
if (pdo_num_rows($query) == 0) {
echo "No coverage entries found for this project";
return;
}
$query_array = pdo_fetch_array($query);
$buildid = $query_array['buildid'];
// Find the coverage files
$query = pdo_query("SELECT cf.fullpath,c.loctested,c.locuntested FROM coverage as c,coveragefile as cf\n WHERE c.fileid=cf.id AND c.buildid='" . $buildid . "' ORDER BY cf.fullpath ASC");
echo pdo_error();
$coveragearray = array();
while ($query_array = pdo_fetch_array($query)) {
$fullpath = $query_array['fullpath'];
$paths = explode('/', $fullpath);
$current = array();
for ($i = 1; $i < count($paths) - 1; $i++) {
if ($i == 1) {
if (!isset($coveragearray[$paths[$i]])) {
$coveragearray[$paths[$i]] = array();
}
$current =& $coveragearray[$paths[$i]];
} else {
if ($i == count($paths) - 2) {
if (isset($current[$paths[$i]])) {
$v = $current[$paths[$i]]['locuntested'];
$current[$paths[$i]]['locuntested'] = (int) $v + $query_array['locuntested'];
$v = $current[$paths[$i]]['loctested'];
$current[$paths[$i]]['loctested'] = (int) $v + $query_array['loctested'];
} else {
@($current[$paths[$i]]['locuntested'] = $query_array['locuntested']);
@($current[$paths[$i]]['loctested'] = $query_array['loctested']);
}
unset($current);
} else {
$current[$paths[$i]] = array();
$current[$paths[$i]]['locuntested'] = 0;
$current[$paths[$i]]['loctested'] = 0;
$current =& $current[$paths[$i]];
}
}
}
}
return $coveragearray;
}
示例2: ListDefects
/** List Defects */
private function ListDefects()
{
include_once 'cdash/common.php';
if (!isset($this->Parameters['project'])) {
echo "Project not set";
return;
}
$projectid = get_project_id($this->Parameters['project']);
if (!is_numeric($projectid) || $projectid <= 0) {
echo "Project not found";
return;
}
// We need multiple queries (4 to be exact)
// First for the build failures
$users = array();
$query = pdo_query("SELECT SUM(errors) AS nerrors,SUM(nfiles) AS nfiles,author FROM(\n SELECT b.id,bed.difference_positive AS errors,u.author,\n COUNT(u.author) AS nfiles, COUNT(DISTINCT u.author) AS dauthor\n FROM build2group AS b2g, buildgroup AS bg,updatefile AS u,build2update AS b2u, builderrordiff AS bed, build AS b\n WHERE b.projectid=" . $projectid . " AND u.updateid=b2u.updateid AND b2u.buildid=b.id AND b2g.buildid=b.id AND b2g.groupid=bg.id AND bg.name!='Experimental'\n AND bed.buildid=b.id AND bed.difference_positive>0 AND bed.difference_negative!=bed.difference_positive\n AND b.starttime<NOW()\n GROUP BY b.id,bed.difference_positive,u.author HAVING COUNT(DISTINCT u.author)=1) AS q GROUP BY author");
echo pdo_error();
while ($query_array = pdo_fetch_array($query)) {
$users[$query_array['author']]['builderrors'] = $query_array['nerrors'];
$users[$query_array['author']]['builderrorsfiles'] = $query_array['nfiles'];
}
// Then for the build fixes
$query = pdo_query("SELECT SUM(fixes) AS nfixes,SUM(nfiles) AS nfiles,author FROM(\n SELECT b.id,bed.difference_positive AS errors,bed.difference_negative AS fixes,u.author,\n COUNT(u.author) AS nfiles, COUNT(DISTINCT u.author) AS dauthor\n FROM build2group AS b2g, buildgroup AS bg,updatefile AS u,build2update AS b2u, builderrordiff AS bed, build AS b\n WHERE b.projectid=" . $projectid . " AND u.updateid=b2u.updateid AND b2u.buildid=b.id AND b2g.buildid=b.id AND b2g.groupid=bg.id AND bg.name!='Experimental'\n AND bed.buildid=b.id AND bed.difference_negative>0 AND bed.difference_positive<bed.difference_negative\n AND b.starttime<NOW()\n GROUP BY b.id,bed.difference_positive,bed.difference_negative,u.author HAVING COUNT(DISTINCT u.author)=1) AS q GROUP BY author");
echo pdo_error();
while ($query_array = pdo_fetch_array($query)) {
$users[$query_array['author']]['buildfixes'] = $query_array['nfixes'];
$users[$query_array['author']]['buildfixesfiles'] = $query_array['nfiles'];
}
// Then for the test failures
$query = pdo_query("SELECT SUM(testerrors) AS ntesterrors,SUM(nfiles) AS nfiles,author FROM(SELECT b.id, td.difference_positive AS testerrors,\n u.author,COUNT(u.author) AS nfiles, COUNT(DISTINCT u.author) AS dauthor\n FROM build2group AS b2g, buildgroup AS bg,updatefile AS u, build2update AS b2u, build AS b, testdiff AS td\n WHERE b.projectid=" . $projectid . " AND u.updateid=b2u.updateid AND b2u.buildid=b.id AND b2g.buildid=b.id AND b2g.groupid=bg.id AND bg.name!='Experimental'\n AND td.buildid=b.id AND td.difference_positive>0 AND td.type=1\n AND b.starttime<NOW()\n GROUP BY b.id,td.difference_positive,u.author HAVING COUNT(DISTINCT u.author)=1) AS q GROUP BY author");
echo pdo_error();
while ($query_array = pdo_fetch_array($query)) {
$users[$query_array['author']]['testerrors'] = $query_array['ntesterrors'];
$users[$query_array['author']]['testerrorsfiles'] = $query_array['nfiles'];
}
// Then for the test fixes
$query = pdo_query("SELECT SUM(testfixes) AS ntestfixes,SUM(nfiles) AS nfiles,author FROM(SELECT b.id, td.difference_positive AS testfixes,\n u.author,COUNT(u.author) AS nfiles, COUNT(DISTINCT u.author) AS dauthor\n FROM build2group AS b2g, buildgroup AS bg,updatefile AS u, build2update AS b2u, build AS b, testdiff AS td\n WHERE b.projectid=" . $projectid . " AND u.updateid=b2u.updateid AND b2u.buildid=b.id AND b2g.buildid=b.id AND b2g.groupid=bg.id AND bg.name!='Experimental'\n AND td.buildid=b.id AND td.difference_positive>0 AND td.type=2 AND td.difference_negative=0\n AND b.starttime<NOW()\n GROUP BY b.id,td.difference_positive,u.author HAVING COUNT(DISTINCT u.author)=1) AS q GROUP BY author");
echo pdo_error();
while ($query_array = pdo_fetch_array($query)) {
$users[$query_array['author']]['testfixes'] = $query_array['ntestfixes'];
$users[$query_array['author']]['testfixesfiles'] = $query_array['nfiles'];
}
// Another select for neutral
$query = pdo_query("SELECT b.id, bed.difference_positive AS errors,\n u.author AS author,count(*) AS nfiles\n FROM build2group AS b2g, buildgroup AS bg,updatefile AS u, build2update AS b2u, build AS b\n LEFT JOIN builderrordiff AS bed ON (bed.buildid=b.id AND difference_positive!=difference_negative)\n LEFT JOIN testdiff AS t ON (t.buildid=b.id)\n WHERE b.projectid=" . $projectid . " AND u.updateid=b2u.updateid AND b2u.buildid=b.id AND b2g.buildid=b.id AND b2g.groupid=bg.id AND bg.name!='Experimental'\n AND bed.difference_positive IS NULL\n AND t.difference_positive IS NULL\n AND b.starttime<NOW() GROUP BY u.author,b.id,bed.difference_positive");
echo pdo_error();
while ($query_array = pdo_fetch_array($query)) {
$users[$query_array['author']]['neutralfiles'] = $query_array['nfiles'];
}
return $users;
}
示例3: get_dynamic_builds
function get_dynamic_builds($projectid, $end_UTCDate)
{
$builds = array();
// Get the build rules for each dynamic group belonging to this project.
$rules = pdo_query("\n SELECT b2gr.buildname, b2gr.siteid, b2gr.parentgroupid, bg.id, bg.name,\n bg.type, gp.position\n FROM build2grouprule AS b2gr\n LEFT JOIN buildgroup AS bg ON (bg.id = b2gr.groupid)\n LEFT JOIN buildgroupposition AS gp ON (gp.buildgroupid=bg.id)\n WHERE bg.projectid='{$projectid}' AND bg.endtime='1980-01-01 00:00:00' AND\n bg.type != 'Daily'");
if (!$rules) {
echo pdo_error();
return;
}
while ($rule = pdo_fetch_array($rules)) {
$buildgroup_name = $rule['name'];
$buildgroup_id = $rule['id'];
$buildgroup_position = $rule['position'];
if ($rule['type'] == 'Latest') {
// optional fields: parentgroupid, site, and build name match.
// Use these to construct a WHERE clause for our query.
$where = '';
$whereClauses = array();
if (!empty($rule['parentgroupid'])) {
$whereClauses[] = "b2g.groupid='" . $rule['parentgroupid'] . "'";
}
if (!empty($rule['siteid'])) {
$whereClauses[] = "s.id='" . $rule['siteid'] . "'";
}
if (!empty($rule['buildname'])) {
$whereClauses[] = "b.name LIKE '" . $rule['buildname'] . "'";
}
if (!empty($whereClauses)) {
$where = 'WHERE ' . implode($whereClauses, ' AND ');
$where .= " AND b.starttime<'{$end_UTCDate}'";
}
// We only want the most recent build.
$order = 'ORDER BY b.submittime DESC LIMIT 1';
$sql = get_index_query();
$sql .= "{$where} {$order}";
$build = pdo_single_row_query($sql);
if (empty($build)) {
continue;
}
$build['groupname'] = $buildgroup_name;
$build['groupid'] = $buildgroup_id;
$build['position'] = $buildgroup_position;
$builds[] = $build;
}
}
return $builds;
}
示例4: get_dynamic_builds
function get_dynamic_builds($projectid)
{
$builds = array();
// Get the build rules for each dynamic group belonging to this project.
$rules = pdo_query("\n SELECT b2gr.buildname, b2gr.siteid, b2gr.parentgroupid, bg.id, bg.name,\n bg.type, gp.position\n FROM build2grouprule AS b2gr\n LEFT JOIN buildgroup AS bg ON (bg.id = b2gr.groupid)\n LEFT JOIN buildgroupposition AS gp ON (gp.buildgroupid=bg.id)\n WHERE bg.projectid='{$projectid}' AND bg.endtime='1980-01-01 00:00:00' AND\n bg.type != 'Daily'");
if (!$rules) {
echo pdo_error();
return;
}
while ($rule = pdo_fetch_array($rules)) {
$buildgroup_name = $rule['name'];
$buildgroup_id = $rule['id'];
$buildgroup_position = $rule['position'];
if ($rule['type'] == 'Latest') {
// optional fields: parentgroupid, site, and build name match.
// Use these to construct a WHERE clause for our query.
$where = "";
$whereClauses = array();
if (!empty($rule['parentgroupid'])) {
$whereClauses[] = "b2g.groupid='" . $rule['parentgroupid'] . "'";
}
if (!empty($rule['siteid'])) {
$whereClauses[] = "s.id='" . $rule['siteid'] . "'";
}
if (!empty($rule['buildname'])) {
$whereClauses[] = "b.name LIKE '" . $rule['buildname'] . "'";
}
if (!empty($whereClauses)) {
$where = "WHERE " . implode($whereClauses, " AND ");
}
// We only want the most recent build.
$order = "ORDER BY b.submittime DESC LIMIT 1";
// Copied from index.php.
$sql = "SELECT b.id,b.siteid,b.parentid,\n bu.status AS updatestatus,\n i.osname AS osname,\n bu.starttime AS updatestarttime,\n bu.endtime AS updateendtime,\n bu.nfiles AS countupdatefiles,\n bu.warnings AS countupdatewarnings,\n c.status AS configurestatus,\n c.starttime AS configurestarttime,\n c.endtime AS configureendtime,\n be_diff.difference_positive AS countbuilderrordiffp,\n be_diff.difference_negative AS countbuilderrordiffn,\n bw_diff.difference_positive AS countbuildwarningdiffp,\n bw_diff.difference_negative AS countbuildwarningdiffn,\n ce_diff.difference AS countconfigurewarningdiff,\n btt.time AS testsduration,\n tnotrun_diff.difference_positive AS counttestsnotrundiffp,\n tnotrun_diff.difference_negative AS counttestsnotrundiffn,\n tfailed_diff.difference_positive AS counttestsfaileddiffp,\n tfailed_diff.difference_negative AS counttestsfaileddiffn,\n tpassed_diff.difference_positive AS counttestspasseddiffp,\n tpassed_diff.difference_negative AS counttestspasseddiffn,\n tstatusfailed_diff.difference_positive AS countteststimestatusfaileddiffp,\n tstatusfailed_diff.difference_negative AS countteststimestatusfaileddiffn,\n (SELECT count(buildid) FROM build2note WHERE buildid=b.id) AS countnotes,\n (SELECT count(buildid) FROM buildnote WHERE buildid=b.id) AS countbuildnotes,\n s.name AS sitename,\n s.outoforder AS siteoutoforder,\n b.stamp,b.name,b.type,b.generator,b.starttime,b.endtime,b.submittime,\n b.configureerrors AS countconfigureerrors,\n b.configurewarnings AS countconfigurewarnings,\n b.builderrors AS countbuilderrors,\n b.buildwarnings AS countbuildwarnings,\n b.testnotrun AS counttestsnotrun,\n b.testfailed AS counttestsfailed,\n b.testpassed AS counttestspassed,\n b.testtimestatusfailed AS countteststimestatusfailed,\n sp.id AS subprojectid,\n sp.groupid AS subprojectgroup,\n (SELECT count(buildid) FROM errorlog WHERE buildid=b.id) AS nerrorlog,\n (SELECT count(buildid) FROM build2uploadfile WHERE buildid=b.id) AS builduploadfiles\n FROM build AS b\n LEFT JOIN build2group AS b2g ON (b2g.buildid=b.id)\n LEFT JOIN buildgroup AS g ON (g.id=b2g.groupid)\n LEFT JOIN site AS s ON (s.id=b.siteid)\n LEFT JOIN build2update AS b2u ON (b2u.buildid=b.id)\n LEFT JOIN buildupdate AS bu ON (b2u.updateid=bu.id)\n LEFT JOIN configure AS c ON (c.buildid=b.id)\n LEFT JOIN buildinformation AS i ON (i.buildid=b.id)\n LEFT JOIN builderrordiff AS be_diff ON (be_diff.buildid=b.id AND be_diff.type=0)\n LEFT JOIN builderrordiff AS bw_diff ON (bw_diff.buildid=b.id AND bw_diff.type=1)\n LEFT JOIN configureerrordiff AS ce_diff ON (ce_diff.buildid=b.id AND ce_diff.type=1)\n LEFT JOIN buildtesttime AS btt ON (btt.buildid=b.id)\n LEFT JOIN testdiff AS tnotrun_diff ON (tnotrun_diff.buildid=b.id AND tnotrun_diff.type=0)\n LEFT JOIN testdiff AS tfailed_diff ON (tfailed_diff.buildid=b.id AND tfailed_diff.type=1)\n LEFT JOIN testdiff AS tpassed_diff ON (tpassed_diff.buildid=b.id AND tpassed_diff.type=2)\n LEFT JOIN testdiff AS tstatusfailed_diff ON (tstatusfailed_diff.buildid=b.id AND tstatusfailed_diff.type=3)\n LEFT JOIN subproject2build AS sp2b ON (sp2b.buildid = b.id)\n LEFT JOIN subproject as sp ON (sp2b.subprojectid = sp.id)\n LEFT JOIN label2build AS l2b ON (l2b.buildid = b.id)\n LEFT JOIN label AS l ON (l.id = l2b.labelid) {$where} {$order}";
$build = pdo_single_row_query($sql);
if (empty($build)) {
continue;
}
$build['groupname'] = $buildgroup_name;
$build['groupid'] = $buildgroup_id;
$build['position'] = $buildgroup_position;
$builds[] = $build;
}
}
return $builds;
}
示例5: Insert
function Insert()
{
if (!is_numeric($this->ProjectId) || !is_numeric($this->BuildId) || !is_numeric($this->ResourceId) || !is_numeric($this->ResourceType) || !is_numeric($this->Type)) {
return false;
}
$description = pdo_real_escape_string($this->Description);
// If the projectid is not set but the buildid is we are trying to find
// the projectid
if ($this->ProjectId == 0 && $this->BuildId > 0) {
$query = pdo_query("SELECT projectid FROM build WHERE id='" . $this->BuildId . "'");
if (pdo_num_rows($query) > 0) {
$query_array = pdo_fetch_array($query);
$this->ProjectId = $query_array['projectid'];
}
}
// Insert a new row every time an error exists
$now = date("Y-m-d H:i:s");
$sql = "INSERT INTO errorlog (projectid,buildid,type,date,resourcetype,resourceid,description)\n VALUES ('" . $this->ProjectId . "','" . $this->BuildId . "','" . $this->Type . "','" . $now . "','" . $this->ResourceType . "','" . $this->ResourceId . "','" . $description . "')";
pdo_query($sql);
echo pdo_error();
// We don't log on purpose (loop loop ;)
return true;
}
示例6: rest_post
function rest_post()
{
global $projectid;
if (isset($_POST['newbuildgroup'])) {
// Create a new buildgroup
$BuildGroup = new BuildGroup();
$BuildGroup->SetProjectId($projectid);
$name = htmlspecialchars(pdo_real_escape_string($_POST['newbuildgroup']));
// Avoid creating a group that uses one of the default names.
if ($name == "Nightly" || $name == "Experimental" || $name == "Continuous") {
echo_error("You cannot create a group named 'Nightly','Experimental' or 'Continuous'");
return;
}
$type = htmlspecialchars(pdo_real_escape_string($_POST['type']));
$BuildGroup->SetName($name);
$BuildGroup->SetType($type);
$BuildGroup->Save();
// Respond with a JSON representation of this new buildgroup
$response = array();
$response['id'] = $BuildGroup->GetId();
$response['name'] = $BuildGroup->GetName();
$response['autoremovetimeframe'] = $BuildGroup->GetAutoRemoveTimeFrame();
echo json_encode($response);
return;
}
if (isset($_POST['newLayout'])) {
// Update the order of the buildgroups for this project.
$inputRows = $_POST['newLayout'];
if (count($inputRows) > 0) {
// Remove old build group layout for this project.
global $CDASH_DB_TYPE;
if (isset($CDASH_DB_TYPE) && $CDASH_DB_TYPE == "pgsql") {
// We use a subquery here because postgres doesn't support
// JOINs in a DELETE statement.
$sql = "\n DELETE FROM buildgroupposition WHERE buildgroupid IN\n (SELECT bgp.buildgroupid FROM buildgroupposition AS bgp\n LEFT JOIN buildgroup AS bg ON (bgp.buildgroupid = bg.id)\n WHERE bg.projectid = '{$projectid}')";
} else {
$sql = "\n DELETE bgp FROM buildgroupposition AS bgp\n LEFT JOIN buildgroup AS bg ON (bgp.buildgroupid = bg.id)\n WHERE bg.projectid = '{$projectid}'";
}
pdo_query($sql);
add_last_sql_error("manageBuildGroup::newLayout::DELETE", $projectid);
// construct query to insert the new layout
$query = "INSERT INTO buildgroupposition (buildgroupid, position) VALUES ";
foreach ($inputRows as $inputRow) {
$query .= "(" . qnum(pdo_real_escape_numeric($inputRow["buildgroupid"])) . ", " . qnum(pdo_real_escape_numeric($inputRow["position"])) . "), ";
}
// remove the trailing comma and space, then insert our new values
$query = rtrim($query, ", ");
pdo_query($query);
add_last_sql_error("API::buildgroup::newLayout::INSERT", $projectid);
}
return;
}
if (isset($_POST['builds'])) {
// Move builds to a new group.
$group = $_POST['group'];
if ($group['id'] < 1) {
echo_error("Please select a group for these builds");
return;
}
$builds = $_POST['builds'];
if (array_key_exists('expected', $_POST)) {
$expected = $_POST['expected'];
} else {
$expected = 0;
}
foreach ($builds as $buildinfo) {
$groupid = pdo_real_escape_numeric($group['id']);
$Build = new Build();
$buildid = pdo_real_escape_numeric($buildinfo['id']);
$Build->Id = $buildid;
$Build->FillFromId($Build->Id);
$prevgroupid = $Build->GroupId;
// Change the group for this build.
pdo_query("UPDATE build2group SET groupid='{$groupid}'\n WHERE groupid='{$prevgroupid}' AND buildid='{$buildid}'");
// Delete any previous rules
pdo_query("\n DELETE FROM build2grouprule\n WHERE groupid='{$prevgroupid}' AND buildtype='{$Build->Type}' AND\n buildname='{$Build->Name}' AND siteid='{$Build->SiteId}'");
// Add the new rule
pdo_query("\n INSERT INTO build2grouprule\n (groupid,buildtype,buildname,siteid,expected,starttime,endtime)\n VALUES\n ('{$groupid}','{$Build->Type}','{$Build->Name}','{$Build->SiteId}',\n '{$expected}','1980-01-01 00:00:00','1980-01-01 00:00:00')");
}
}
if (isset($_POST['nameMatch'])) {
// Define a BuildGroup by Build name.
$group = $_POST['group'];
$groupid = $group['id'];
if ($groupid < 1) {
echo_error("Please select a BuildGroup to define.");
return;
}
$nameMatch = "%" . htmlspecialchars(pdo_real_escape_string($_POST["nameMatch"])) . "%";
$type = htmlspecialchars(pdo_real_escape_string($_POST["type"]));
$sql = "INSERT INTO build2grouprule (groupid, buildtype, buildname, siteid)\n VALUES ('{$groupid}', '{$type}', '{$nameMatch}', '-1')";
if (!pdo_query($sql)) {
echo_error(pdo_error());
}
}
if (isset($_POST['dynamic']) && !empty($_POST['dynamic'])) {
// Add a build row to a dynamic group
$groupid = pdo_real_escape_numeric($_POST['dynamic']['id']);
if (empty($_POST['buildgroup'])) {
$parentgroupid = 0;
//.........这里部分代码省略.........
示例7: session_start
<?php
session_start();
include_once "pdo_mysql.php";
if (isset($_POST['submit_signup'])) {
$username = 'pnguyen';
$password = '00000949559';
$host = 'dbserver.engr.scu.edu';
$database = 'sdb_pnguyen';
if (!($server = pdo_connect("{$host}", $username, $password))) {
die('Error connecting to ' . $host . '.' . pdo_error());
}
if (!($conn = pdo_select_db($database, $server))) {
die('Error selecting ' . $database . '.' . pdo_error());
}
$user = $_POST['name'];
if ($_POST['password'] == $_POST['password2']) {
$password = $_POST['password'];
$email = $_POST['email'];
$NewRequestQuery = "INSERT INTO `enqueue_login` (`user`, `email`, `password`, `isInstructor`) VALUES ('{$user}', '{$email}', '{$password}', '0')";
pdo_query($NewRequestQuery);
echo "Success! Redirecting to home...";
header("refresh:3; url= landing_page.php");
} else {
echo "Your passwords did not match! Redirecting to signup...";
header("refresh:3; url=signup.php");
}
}
示例8: array
}
$dynamics_response[] = $dynamic_response;
}
}
$response['buildgroups'] = $buildgroups_response;
$response['dynamics'] = $dynamics_response;
// Store some additional details about this project.
$project_response = array();
$project_response['id'] = $projectid;
$project_name = $Project->GetName();
$project_response['name'] = $project_name;
$project_response['name_encoded'] = urlencode($project_name);
$response['project'] = $project_response;
// Generate response for any wildcard groups.
$wildcards = pdo_query("\n SELECT bg.name, bg.id, b2gr.buildtype, b2gr.buildname\n FROM build2grouprule AS b2gr, buildgroup AS bg\n WHERE b2gr.buildname LIKE '\\%%\\%' AND b2gr.groupid = bg.id AND\n bg.type = 'Daily' AND bg.projectid='{$projectid}'");
$err = pdo_error();
if (!empty($err)) {
$response['error'] = $err;
}
$wildcards_response = array();
while ($wildcard_array = pdo_fetch_array($wildcards)) {
$wildcard_response = array();
$wildcard_response['buildgroupname'] = $wildcard_array['name'];
$wildcard_response['buildgroupid'] = $wildcard_array['id'];
$wildcard_response['buildtype'] = $wildcard_array['buildtype'];
$match = $wildcard_array['buildname'];
$match = str_replace("%", "", $match);
$wildcard_response['match'] = $match;
$wildcards_response[] = $wildcard_response;
}
$response['wildcards'] = $wildcards_response;
示例9: Insert
/** Insert a new site */
public function Insert()
{
$justSetIP = false;
if (strlen($this->Ip) == 0) {
$this->LookupIP();
$justSetIP = true;
}
if ($this->Exists()) {
if ($justSetIP) {
$this->Update();
}
return $this->Id;
}
// Get the geolocation
if (strlen($this->Latitude) == 0) {
$location = get_geolocation($this->Ip);
$this->Latitude = $location['latitude'];
$this->Longitude = $location['longitude'];
}
$query = "INSERT INTO site (name,ip,latitude,longitude)\n VALUES\n ('{$this->Name}','{$this->Ip}','{$this->Latitude}','{$this->Longitude}')";
if (!pdo_query($query)) {
$error = pdo_error();
// This error might be due to a unique constraint violation.
// Query for a previously existing site with this name & ip.
$existing_id_result = pdo_single_row_query("SELECT id FROM site WHERE name='{$this->Name}'\n AND ip='{$this->Ip}'");
if ($existing_id_result && array_key_exists('id', $existing_id_result)) {
$this->Id = $existing_id_result['id'];
return true;
}
add_log("SQL error: {$error}", 'Site Insert', LOG_ERR);
return false;
} else {
$this->Id = pdo_insert_id('site');
}
}
示例10: get_projects
/** return an array of public projects */
function get_projects($onlyactive = true)
{
$projects = array();
include "cdash/config.php";
require_once "cdash/pdo.php";
require_once 'models/project.php';
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
$projectres = pdo_query("SELECT id,name,description FROM project WHERE public='1' ORDER BY name");
while ($project_array = pdo_fetch_array($projectres)) {
$project = array();
$project['id'] = $project_array["id"];
$project['name'] = $project_array["name"];
$project['description'] = $project_array["description"];
$projectid = $project['id'];
$project['last_build'] = "NA";
$lastbuildquery = pdo_query("SELECT submittime FROM build WHERE projectid='{$projectid}' ORDER BY submittime DESC LIMIT 1");
if (pdo_num_rows($lastbuildquery) > 0) {
$lastbuild_array = pdo_fetch_array($lastbuildquery);
$project['last_build'] = $lastbuild_array["submittime"];
}
// Display if the project is considered active or not
$dayssincelastsubmission = $CDASH_ACTIVE_PROJECT_DAYS + 1;
if ($project['last_build'] != 'NA') {
$dayssincelastsubmission = (time() - strtotime($project['last_build'])) / 86400;
}
$project['dayssincelastsubmission'] = $dayssincelastsubmission;
if ($project['last_build'] != 'NA' && $project['dayssincelastsubmission'] <= $CDASH_ACTIVE_PROJECT_DAYS) {
// Get the number of builds in the past 7 days
$submittime_UTCDate = gmdate(FMT_DATETIME, time() - 604800);
$buildquery = pdo_query("SELECT count(id) FROM build WHERE projectid='{$projectid}' AND starttime>'" . $submittime_UTCDate . "'");
echo pdo_error();
$buildquery_array = pdo_fetch_array($buildquery);
$project['nbuilds'] = $buildquery_array[0];
}
/** Not showing the upload size for now for performance reasons */
//$Project = new Project;
//$Project->Id = $project['id'];
//$project['uploadsize'] = $Project->GetUploadsTotalSize();
if (!$onlyactive || $project['dayssincelastsubmission'] <= $CDASH_ACTIVE_PROJECT_DAYS) {
$projects[] = $project;
}
}
return $projects;
}
示例11: echo_main_dashboard_JSON
//.........这里部分代码省略.........
// add a request for the subproject
$subprojectsql = '';
if ($subproject_name && is_numeric($subprojectid)) {
$subprojectsql = ' AND sp2b.subprojectid=' . $subprojectid;
}
// Use this as the default date clause, but if $filterdata has a date clause,
// then cancel this one out:
//
$date_clause = "AND b.starttime<'{$end_UTCDate}' AND b.starttime>='{$beginning_UTCDate}' ";
if ($filterdata['hasdateclause']) {
$date_clause = '';
}
$parent_clause = '';
if (isset($_GET['parentid'])) {
// If we have a parentid, then we should only show children of that build.
// Date becomes irrelevant in this case.
$parent_clause = 'AND (b.parentid = ' . qnum($_GET['parentid']) . ') ';
$date_clause = '';
} elseif (empty($subprojectsql)) {
// Only show builds that are not children.
$parent_clause = 'AND (b.parentid = -1 OR b.parentid = 0) ';
}
$build_rows = array();
// If the user is logged in we display if the build has some changes for him
$userupdatesql = '';
if (isset($_SESSION['cdash']) && array_key_exists('loginid', $_SESSION['cdash'])) {
$userupdatesql = "(SELECT count(updatefile.updateid) FROM updatefile,build2update,user2project,\n user2repository\n WHERE build2update.buildid=b.id\n AND build2update.updateid=updatefile.updateid\n AND user2project.projectid=b.projectid\n AND user2project.userid='" . $_SESSION['cdash']['loginid'] . "'\n AND user2repository.userid=user2project.userid\n AND (user2repository.projectid=0 OR user2repository.projectid=b.projectid)\n AND user2repository.credential=updatefile.author) AS userupdates,";
}
$sql = get_index_query();
$sql .= "WHERE b.projectid='{$projectid}' AND g.type='Daily'\n {$parent_clause} {$date_clause} {$subprojectsql} {$filter_sql} {$limit_sql}";
// We shouldn't get any builds for group that have been deleted (otherwise something is wrong)
$builds = pdo_query($sql);
// Log any errors
$pdo_error = pdo_error();
if (strlen($pdo_error) > 0) {
add_log('SQL error: ' . $pdo_error, 'Index.php', LOG_ERR);
}
// Gather up results from this query.
$build_data = array();
while ($build_row = pdo_fetch_array($builds)) {
$build_data[] = $build_row;
}
$dynamic_builds = array();
if (empty($filter_sql)) {
$dynamic_builds = get_dynamic_builds($projectid, $end_UTCDate);
$build_data = array_merge($build_data, $dynamic_builds);
}
// Check if we need to summarize coverage by subproject groups.
// This happens when we have subprojects and we're looking at the children
// of a specific build.
$coverage_groups = array();
if (isset($_GET['parentid']) && $_GET['parentid'] > 0 && $project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) {
$groups = $project_instance->GetSubProjectGroups();
foreach ($groups as $group) {
// Keep track of coverage info on a per-group basis.
$groupId = $group->GetId();
$coverage_groups[$groupId] = array();
$coverageThreshold = $group->GetCoverageThreshold();
$coverage_groups[$groupId]['thresholdgreen'] = $coverageThreshold;
$coverage_groups[$groupId]['thresholdyellow'] = $coverageThreshold * 0.7;
$coverage_groups[$groupId]['label'] = $group->GetName();
$coverage_groups[$groupId]['loctested'] = 0;
$coverage_groups[$groupId]['locuntested'] = 0;
$coverage_groups[$groupId]['position'] = $group->GetPosition();
$coverage_groups[$groupId]['coverages'] = array();
}
示例12: generate_main_dashboard_XML
//.........这里部分代码省略.........
$date_clause = "AND b.starttime<'{$end_UTCDate}' AND b.starttime>='{$beginning_UTCDate}' ";
if ($filterdata['hasdateclause']) {
$date_clause = '';
}
$parent_clause = "";
if (isset($_GET["parentid"])) {
// If we have a parentid, then we should only show children of that build.
// Date becomes irrelevant in this case.
$parent_clause = "AND (b.parentid = " . qnum($_GET["parentid"]) . ") ";
$date_clause = "";
} else {
if (empty($subprojectsql)) {
// Only show builds that are not children.
$parent_clause = "AND (b.parentid = -1 OR b.parentid = 0) ";
}
}
$build_rows = array();
// If the user is logged in we display if the build has some changes for him
$userupdatesql = "";
if (isset($_SESSION['cdash'])) {
$userupdatesql = "(SELECT count(updatefile.updateid) FROM updatefile,build2update,user2project,\n user2repository\n WHERE build2update.buildid=b.id\n AND build2update.updateid=updatefile.updateid\n AND user2project.projectid=b.projectid\n AND user2project.userid='" . $_SESSION['cdash']['loginid'] . "'\n AND user2repository.userid=user2project.userid\n AND (user2repository.projectid=0 OR user2repository.projectid=b.projectid)\n AND user2repository.credential=updatefile.author) AS userupdates,";
}
// Postgres differs from MySQL on how to aggregate results
// into a single column.
$label_sql = "";
$groupby_sql = "";
if ($CDASH_DB_TYPE != 'pgsql') {
$label_sql = "GROUP_CONCAT(l.text SEPARATOR ', ') AS labels,";
$groupby_sql = " GROUP BY b.id";
}
$sql = "SELECT b.id,b.siteid,b.parentid,\n bu.status AS updatestatus,\n i.osname AS osname,\n bu.starttime AS updatestarttime,\n bu.endtime AS updateendtime,\n bu.nfiles AS countupdatefiles,\n bu.warnings AS countupdatewarnings,\n c.status AS configurestatus,\n c.starttime AS configurestarttime,\n c.endtime AS configureendtime,\n be_diff.difference_positive AS countbuilderrordiffp,\n be_diff.difference_negative AS countbuilderrordiffn,\n bw_diff.difference_positive AS countbuildwarningdiffp,\n bw_diff.difference_negative AS countbuildwarningdiffn,\n ce_diff.difference AS countconfigurewarningdiff,\n btt.time AS testsduration,\n tnotrun_diff.difference_positive AS counttestsnotrundiffp,\n tnotrun_diff.difference_negative AS counttestsnotrundiffn,\n tfailed_diff.difference_positive AS counttestsfaileddiffp,\n tfailed_diff.difference_negative AS counttestsfaileddiffn,\n tpassed_diff.difference_positive AS counttestspasseddiffp,\n tpassed_diff.difference_negative AS counttestspasseddiffn,\n tstatusfailed_diff.difference_positive AS countteststimestatusfaileddiffp,\n tstatusfailed_diff.difference_negative AS countteststimestatusfaileddiffn,\n (SELECT count(buildid) FROM build2note WHERE buildid=b.id) AS countnotes,\n (SELECT count(buildid) FROM buildnote WHERE buildid=b.id) AS countbuildnotes," . $userupdatesql . "\n s.name AS sitename,\n s.outoforder AS siteoutoforder,\n b.stamp,b.name,b.type,b.generator,b.starttime,b.endtime,b.submittime,\n b.configureerrors AS countconfigureerrors,\n b.configurewarnings AS countconfigurewarnings,\n b.builderrors AS countbuilderrors,\n b.buildwarnings AS countbuildwarnings,\n b.testnotrun AS counttestsnotrun,\n b.testfailed AS counttestsfailed,\n b.testpassed AS counttestspassed,\n b.testtimestatusfailed AS countteststimestatusfailed,\n sp.id AS subprojectid,\n sp.groupid AS subprojectgroup,\n g.name as groupname,gp.position,g.id as groupid,\n {$label_sql}\n (SELECT count(buildid) FROM errorlog WHERE buildid=b.id) AS nerrorlog,\n (SELECT count(buildid) FROM build2uploadfile WHERE buildid=b.id) AS builduploadfiles\n FROM build AS b\n LEFT JOIN build2group AS b2g ON (b2g.buildid=b.id)\n LEFT JOIN buildgroup AS g ON (g.id=b2g.groupid)\n LEFT JOIN buildgroupposition AS gp ON (gp.buildgroupid=g.id)\n LEFT JOIN site AS s ON (s.id=b.siteid)\n LEFT JOIN build2update AS b2u ON (b2u.buildid=b.id)\n LEFT JOIN buildupdate AS bu ON (b2u.updateid=bu.id)\n LEFT JOIN configure AS c ON (c.buildid=b.id)\n LEFT JOIN buildinformation AS i ON (i.buildid=b.id)\n LEFT JOIN builderrordiff AS be_diff ON (be_diff.buildid=b.id AND be_diff.type=0)\n LEFT JOIN builderrordiff AS bw_diff ON (bw_diff.buildid=b.id AND bw_diff.type=1)\n LEFT JOIN configureerrordiff AS ce_diff ON (ce_diff.buildid=b.id AND ce_diff.type=1)\n LEFT JOIN buildtesttime AS btt ON (btt.buildid=b.id)\n LEFT JOIN testdiff AS tnotrun_diff ON (tnotrun_diff.buildid=b.id AND tnotrun_diff.type=0)\n LEFT JOIN testdiff AS tfailed_diff ON (tfailed_diff.buildid=b.id AND tfailed_diff.type=1)\n LEFT JOIN testdiff AS tpassed_diff ON (tpassed_diff.buildid=b.id AND tpassed_diff.type=2)\n LEFT JOIN testdiff AS tstatusfailed_diff ON (tstatusfailed_diff.buildid=b.id AND tstatusfailed_diff.type=3)\n LEFT JOIN subproject2build AS sp2b ON (sp2b.buildid = b.id)\n LEFT JOIN subproject as sp ON (sp2b.subprojectid = sp.id)\n LEFT JOIN label2build AS l2b ON (l2b.buildid = b.id)\n LEFT JOIN label AS l ON (l.id = l2b.labelid)\n WHERE b.projectid='{$projectid}' AND g.type='Daily'\n {$parent_clause} {$date_clause}\n " . $subprojectsql . " " . $filter_sql . " " . $groupby_sql . $limit_sql;
// We shouldn't get any builds for group that have been deleted (otherwise something is wrong)
$builds = pdo_query($sql);
echo pdo_error();
// Sort results from this query.
// We used to do this in MySQL with the following directive:
// ORDER BY gp.position ASC,b.name ASC,b.siteid ASC,b.stamp DESC
// But this dramatically impacted performance when the number of rows was
// relatively large (in the thousands). So now we accomplish the same
// sorting within PHP instead.
$build_data = array();
while ($build_row = pdo_fetch_array($builds)) {
$build_data[] = $build_row;
}
$dynamic_builds = array();
if (empty($filter_sql)) {
$dynamic_builds = get_dynamic_builds($projectid);
$build_data = array_merge($build_data, $dynamic_builds);
}
$positions = array();
$names = array();
$siteids = array();
$stamps = array();
foreach ($build_data as $key => $row) {
$positions[$key] = $row['position'];
$names[$key] = $row['name'];
$siteids[$key] = $row['siteid'];
$stamps[$key] = $row['stamp'];
}
array_multisort($positions, SORT_ASC, $names, SORT_ASC, $siteids, SORT_ASC, $stamps, SORT_DESC, $build_data);
// The SQL results are ordered by group so this should work
// Group position have to be continuous
$previousgroupposition = -1;
$received_builds = array();
// Find the last position of the group
$groupposition_array = pdo_fetch_array(pdo_query("SELECT gp.position FROM buildgroupposition AS gp,buildgroup AS g\n WHERE g.projectid='{$projectid}' AND g.id=gp.buildgroupid\n AND gp.starttime<'{$end_UTCDate}' AND (gp.endtime>'{$end_UTCDate}' OR gp.endtime='1980-01-01 00:00:00')\n ORDER BY gp.position DESC LIMIT 1"));
示例13: register_user
function register_user($projectid, $email, $firstName, $lastName, $repositoryCredential)
{
include dirname(__DIR__) . '/config/config.php';
$UserProject = new UserProject();
$UserProject->ProjectId = $projectid;
// Check if the user is already registered
$user = pdo_query('SELECT id FROM ' . qid('user') . " WHERE email='{$email}'");
if (pdo_num_rows($user) > 0) {
// Check if the user has been registered to the project
$user_array2 = pdo_fetch_array($user);
$userid = $user_array2['id'];
$user = pdo_query("SELECT userid FROM user2project WHERE userid='{$userid}' AND projectid='{$projectid}'");
if (pdo_num_rows($user) == 0) {
// not registered
// We register the user to the project
pdo_query("INSERT INTO user2project (userid,projectid,role,emailtype)\n VALUES ('{$userid}','{$projectid}','0','1')");
// We add the credentials if not already added
$UserProject->UserId = $userid;
$UserProject->AddCredential($repositoryCredential);
$UserProject->ProjectId = 0;
$UserProject->AddCredential($email);
// Add the email by default
echo pdo_error();
return false;
}
return '<error>User ' . $email . ' already registered.</error>';
}
// already registered
// Check if the repositoryCredential exists for this project
$UserProject->RepositoryCredential = $repositoryCredential;
if ($UserProject->FillFromRepositoryCredential() === true) {
return '<error>' . $repositoryCredential . ' was already registered for this project under a different email address</error>';
}
// Register the user
// Create a new password
$keychars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$length = 10;
$pass = '';
$max = strlen($keychars) - 1;
for ($i = 0; $i <= $length; $i++) {
// random_int is available in PHP 7 and the random_compat PHP 5.x
// polyfill included in the Composer package.json dependencies.
$pass .= substr($keychars, random_int(0, $max), 1);
}
$encrypted = md5($pass);
pdo_query('INSERT INTO ' . qid('user') . " (email,password,firstname,lastname,institution,admin)\n VALUES ('{$email}','{$encrypted}','{$firstName}','{$lastName}','','0')");
add_last_sql_error('register_user');
$userid = pdo_insert_id('user');
// Insert the user into the project
pdo_query("INSERT INTO user2project (userid,projectid,role,emailtype)\n VALUES ('{$userid}','{$projectid}','0','1')");
add_last_sql_error('register_user');
// We add the credentials if not already added
$UserProject->UserId = $userid;
$UserProject->AddCredential($repositoryCredential);
$UserProject->ProjectId = 0;
$UserProject->AddCredential($email);
// Add the email by default
$currentURI = get_server_URI();
$prefix = '';
if (strlen($firstName) > 0) {
$prefix = ' ';
}
$project = pdo_query("SELECT name FROM project WHERE id='{$projectid}'");
$project_array = pdo_fetch_array($project);
$projectname = $project_array['name'];
// Send the email
$text = 'Hello' . $prefix . $firstName . ",\n\n";
$text .= 'You have been registered to CDash because you have CVS/SVN access to the repository for ' . $projectname . "\n";
$text .= 'To access your CDash account: ' . $currentURI . "/user.php\n";
$text .= 'Your login is: ' . $email . "\n";
$text .= 'Your password is: ' . $pass . "\n\n";
$text .= 'Generated by CDash.';
if (cdashmail("{$email}", 'CDash - ' . $projectname . ' : Subscription', "{$text}")) {
echo 'Email sent to: ' . $email . '<br>';
} else {
add_log("cannot send email to: {$email}", 'register_user', LOG_ERR);
}
return true;
}
示例14: pdo_query_and_log_if_failed
function pdo_query_and_log_if_failed($qry, $caller)
{
$result = pdo_query($qry);
if (FALSE === $result) {
add_log('error: pdo_query failed: ' . pdo_error(), $caller, LOG_ERR);
// Also log a bit of the query so we can tell where it came from:
if (strlen($qry) > 100) {
$log_qry = substr($qry, 0, 100) . '...';
} else {
$log_qry = $qry;
}
add_log('query: ' . $log_qry, $caller, LOG_INFO);
return FALSE;
}
return TRUE;
}
示例15: fillDb
public function fillDb($sqlfile)
{
if (!$this->dbconnect) {
$this->connect();
}
$file_content = file($sqlfile);
//print_r($file_content);
$query = '';
$line_number = 0;
foreach ($file_content as $sql_line) {
$tsl = trim($sql_line);
if ($sql_line != '' && substr($tsl, 0, 2) != '--' && substr($tsl, 0, 1) != '#') {
$query .= $sql_line;
if (preg_match("/;\\s*\$/", $sql_line)) {
$query = str_replace(';', '', "{$query}");
$result = pdo_query($query);
if (!$result) {
echo 'Error line:' . $line_number . '<br/>';
return pdo_error();
}
$query = '';
}
}
$line_number++;
}
$pwd = md5('simpletest');
$query = 'INSERT INTO "user" (email, password, firstname, lastname, institution, admin) ';
$query .= "VALUES ('simpletest@localhost', '{$pwd}', 'administrator', '','Kitware Inc.', 1)";
pdo_query($query);
echo pdo_error();
// Create the language. PgSQL has no way to know if the language already
// exists
@pdo_query('CREATE LANGUAGE plpgsql');
$sqlfile = str_replace('.sql', '.ext.sql', $sqlfile);
// If we are with PostGreSQL we need to add some extra functions
$file_content = file($sqlfile);
$query = '';
foreach ($file_content as $sql_line) {
$tsl = trim($sql_line);
if ($sql_line != '' && substr($tsl, 0, 2) != '--') {
$query .= $sql_line;
if (strpos('CREATE ', $sql_line) !== false) {
// We need to remove only the last semicolon
$pos = strrpos($query, ';');
if ($pos !== false) {
$query = substr($query, 0, $pos) . substr($query, $pos + 1);
}
$result = pdo_query($query);
if (!$result) {
$xml = '<db_created>0</db_created>';
die(pdo_error());
}
$query = '';
}
}
}
// Run the last query
$pos = strrpos($query, ';');
if ($pos !== false) {
$query = substr($query, 0, $pos) . substr($query, $pos + 1);
}
$result = pdo_query($query);
if (!$result) {
$xml = '<db_created>0</db_created>';
die(pdo_error());
}
$this->disconnect();
return true;
}