本文整理汇总了PHP中pdo_num_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP pdo_num_rows函数的具体用法?PHP pdo_num_rows怎么用?PHP pdo_num_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdo_num_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Save
/** Save */
public function Save()
{
$version = pdo_real_escape_string($this->Version);
$path = pdo_real_escape_string($this->Path);
// Check if the version already exists
$query = pdo_query("SELECT id FROM client_cmake WHERE version='" . $version . "'");
if (pdo_num_rows($query) == 0) {
$sql = "INSERT INTO client_cmake (version)\n VALUES ('" . $version . "')";
pdo_query($sql);
$this->Id = pdo_insert_id('client_cmake');
add_last_sql_error('clientCMake::Save()');
} else {
// update
$query_array = pdo_fetch_array($query);
$this->Id = $query_array['id'];
$sql = "UPDATE client_cmake SET version='" . $version . "' WHERE id=" . qnum($this->Id);
pdo_query($sql);
add_last_sql_error('clientCMake::Save()');
}
// Insert into the siteid
$query = pdo_query('SELECT cmakeid FROM client_site2cmake WHERE cmakeid=' . qnum($this->Id) . ' AND siteid=' . qnum($this->SiteId));
if (pdo_num_rows($query) == 0) {
$sql = 'INSERT INTO client_site2cmake (siteid,cmakeid,path)
VALUES (' . qnum($this->SiteId) . ',' . qnum($this->Id) . ",'" . $path . "')";
pdo_query($sql);
add_last_sql_error('clientCMake::Save()');
} else {
// update
$sql = "UPDATE client_site2cmake SET path='" . $path . "' WHERE cmakeid=" . qnum($this->Id) . ' AND siteid=' . qnum($this->SiteId);
pdo_query($sql);
add_last_sql_error('clientCMake::Save()');
}
}
示例2: get_related_dates
function get_related_dates($projectname, $basedate)
{
include "cdash/config.php";
require_once "cdash/pdo.php";
$dates = array();
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
$dbQuery = pdo_query("SELECT nightlytime FROM project WHERE name='{$projectname}'");
if (pdo_num_rows($dbQuery) > 0) {
$project = pdo_fetch_array($dbQuery);
$nightlytime = $project['nightlytime'];
//echo "query result nightlytime: " . $nightlytime . "<br/>";
} else {
$nightlytime = "00:00:00";
//echo "default nightlytime: " . $nightlytime . "<br/>";
}
if (!isset($basedate) || strlen($basedate) == 0) {
$basedate = gmdate(FMT_DATE);
}
// Convert the nightly time into GMT
$nightlytime = gmdate(FMT_TIME, strtotime($nightlytime));
$nightlyhour = time2hour($nightlytime);
$nightlyminute = time2minute($nightlytime);
$nightlysecond = time2second($nightlytime);
$basemonth = date2month($basedate);
$baseday = date2day($basedate);
$baseyear = date2year($basedate);
$dates['nightly+2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 2, $baseyear);
$dates['nightly+1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 1, $baseyear);
$dates['nightly-0'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday, $baseyear);
$dates['nightly-1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 1, $baseyear);
$dates['nightly-2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 2, $baseyear);
// Snapshot of "now"
//
$currentgmtime = time();
$currentgmdate = gmdate(FMT_DATE, $currentgmtime);
// Find the most recently past nightly time:
//
$todaymonth = date2month($currentgmdate);
$todayday = date2day($currentgmdate);
$todayyear = date2year($currentgmdate);
$currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear);
while ($currentnightly > $currentgmtime) {
$todayday = $todayday - 1;
$currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear);
}
$dates['now'] = $currentgmtime;
$dates['most-recent-nightly'] = $currentnightly;
$dates['today_utc'] = $currentgmdate;
$dates['basedate'] = gmdate(FMT_DATE, $dates['nightly-0']);
// CDash equivalent of DART1's "last rollup time"
if ($dates['basedate'] === $dates['today_utc']) {
// If it's today, it's now:
$dates['last-rollup-time'] = $dates['now'];
} else {
// If it's not today, it's the nightly time on the basedate:
$dates['last-rollup-time'] = $dates['nightly-0'];
}
return $dates;
}
示例3: Authenticate
/**
* Authenticate to the web API as a project admin
* @param project the name of the project
* @param key the web API key for that project
*/
function Authenticate()
{
include_once '../cdash/common.php';
if (!isset($this->Parameters['project'])) {
return array('status' => false, 'message' => "You must specify a project parameter.");
}
$projectid = get_project_id($this->Parameters['project']);
if (!is_numeric($projectid) || $projectid <= 0) {
return array('status' => false, 'message' => 'Project not found.');
}
if (!isset($this->Parameters['key']) || $this->Parameters['key'] == '') {
return array('status' => false, 'message' => "You must specify a key parameter.");
}
$key = $this->Parameters['key'];
$query = pdo_query("SELECT webapikey FROM project WHERE id={$projectid}");
if (pdo_num_rows($query) == 0) {
return array('status' => false, 'message' => "Invalid projectid.");
}
$row = pdo_fetch_array($query);
$realKey = $row['webapikey'];
if ($key != $realKey) {
return array('status' => false, 'message' => "Incorrect API key passed.");
}
$token = create_web_api_token($projectid);
return array('status' => true, 'token' => $token);
}
示例4: testTestHistory
public function testTestHistory()
{
// Submit our testing data.
$rep = dirname(__FILE__) . '/data/TestHistory';
if (!$this->submission('InsightExample', "{$rep}/Test_1.xml")) {
$this->fail('Failed to submit Test_1.xml');
return 1;
}
if (!$this->submission('InsightExample', "{$rep}/Test_2.xml")) {
$this->fail('Failed to submit Test_1.xml');
return 1;
}
// Get the IDs for the two builds that we just created.
$result = pdo_query("SELECT id FROM build WHERE name='TestHistory'");
$num_builds = pdo_num_rows($result);
if ($num_builds != 2) {
$this->fail("Expected 2 builds, found {$num_builds}");
return 1;
}
$buildids = array();
while ($row = pdo_fetch_array($result)) {
$buildids[] = $row['id'];
}
// Verify that testing history matches what we expect.
$content = $this->connect($this->url . '/api/v1/viewTest.php?groupid=15&previous_builds=' . $buildids[1] . ',+' . $buildids[0] . '&projectid=5&tests%5B%5D=fails&tests%5B%5D=notrun&tests%5B%5D=flaky&tests%5B%5D=passes&time_begin=2015-11-16T01:00:00&time_end=2015-11-17T01:00:00');
$jsonobj = json_decode($content, true);
$success = true;
$error_message = '';
foreach ($jsonobj['tests'] as $test) {
$history = $test['history'];
if ($test['name'] == 'fails' && $history != 'Broken') {
$error_message = "Expected history for test 'fails' to be 'Broken', instead found '{$history}'";
$success = false;
}
if ($test['name'] == 'notrun' && $history != 'Inactive') {
$error_message = "Expected history for test 'notrun' to be 'Inactive', instead found '{$history}'";
$success = false;
}
if ($test['name'] == 'flaky' && $history != 'Unstable') {
$error_message = "Expected history for test 'flaky' to be 'Unstable', instead found '{$history}'";
$success = false;
}
if ($test['name'] == 'passes' && $history != 'Stable') {
$error_message = "Expected history for test 'passes' to be 'Stable', instead found '{$history}'";
$success = false;
}
}
// Delete the builds that we created during this test.
remove_build($buildids[0]);
remove_build($buildids[1]);
if ($success) {
$this->pass('Test passed');
return 0;
} else {
$this->fail($error_message);
return 1;
}
}
示例5: 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;
}
示例6: get_last_fileid_dynamicanalysis
/** Get the last file id dynamicanalysis */
function get_last_fileid_dynamicanalysis($filename, $projectid, $siteid, $buildtype, $buildname, $starttime)
{
$nextbuild = pdo_query("SELECT dynamicanalysis.id FROM build,dynamicanalysis\n WHERE build.siteid='{$siteid}' AND build.type='{$buildtype}' AND build.name='{$buildname}'\n AND build.projectid='{$projectid}' \n AND dynamicanalysis.buildid=build.id\n AND dynamicanalysis.name='{$filename}'\n ORDER BY build.starttime DESC LIMIT 1");
if (pdo_num_rows($nextbuild) > 0) {
$nextbuild_array = pdo_fetch_array($nextbuild);
return $nextbuild_array["id"];
}
return 0;
}
示例7: Insert
public function Insert()
{
if (!$this->BuildId) {
add_log('BuildId not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id);
return false;
}
if (!$this->Time) {
add_log('Time not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id);
return false;
}
if (!$this->Name) {
add_log('Name not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id);
return false;
}
if (!$this->Text) {
add_log('Text not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id);
return false;
}
// Check if the note already exists
$crc32 = $this->GetCrc32();
$text = pdo_real_escape_string($this->Text);
$timestamp = pdo_real_escape_string($this->Time);
$name = pdo_real_escape_string($this->Name);
$notecrc32 = pdo_query("SELECT id FROM note WHERE crc32='{$crc32}'");
if (pdo_num_rows($notecrc32) == 0) {
if ($this->Id) {
$query = "INSERT INTO note (id,text,name,crc32) VALUES ('{$this->Id}','{$text}','{$name}','{$crc32}')";
} else {
$query = "INSERT INTO note (text,name,crc32) VALUES ('{$text}','{$name}','{$crc32}')";
}
if (!pdo_query($query)) {
add_last_sql_error('BuildNote:Insert', 0, $this->BuildId);
return false;
}
if (!$this->Id) {
$this->Id = pdo_insert_id('note');
}
} else {
// already there
$notecrc32_array = pdo_fetch_array($notecrc32);
$this->Id = $notecrc32_array['id'];
}
if (!$this->Id) {
echo 'BuildNote::Insert(): No NoteId';
return false;
}
$query = "INSERT INTO build2note (buildid,noteid,time)\n VALUES ('{$this->BuildId}','{$this->Id}','{$this->Time}')";
if (!pdo_query($query)) {
add_last_sql_error('BuildNote:Insert', 0, $this->BuildId);
return false;
}
return true;
}
示例8: Insert
function Insert()
{
if (!$this->BuildId) {
echo "BuildNote::Insert(): BuildId is not set<br>";
return false;
}
if (!$this->Time) {
echo "BuildNote::Insert(): Time is not set<br>";
return false;
}
if (!$this->Name) {
echo "BuildNote::Insert(): Name is not set<br>";
return false;
}
if (!$this->Text) {
echo "BuildNote::Insert(): Text is not set<br>";
return false;
}
// Check if the note already exists
$crc32 = $this->GetCrc32();
$text = pdo_real_escape_string($this->Text);
$timestamp = pdo_real_escape_string($this->Time);
$name = pdo_real_escape_string($this->Name);
$notecrc32 = pdo_query("SELECT id FROM note WHERE crc32='{$crc32}'");
if (pdo_num_rows($notecrc32) == 0) {
if ($this->Id) {
$query = "INSERT INTO note (id,text,name,crc32) VALUES ('{$this->Id}','{$text}','{$name}','{$crc32}')";
} else {
$query = "INSERT INTO note (text,name,crc32) VALUES ('{$text}','{$name}','{$crc32}')";
}
if (!pdo_query($query)) {
add_last_sql_error("BuildNote:Insert", 0, $this->BuildId);
return false;
}
if (!$this->Id) {
$this->Id = pdo_insert_id("note");
}
} else {
$notecrc32_array = pdo_fetch_array($notecrc32);
$this->Id = $notecrc32_array["id"];
}
if (!$this->Id) {
echo "BuildNote::Insert(): No NoteId";
return false;
}
$query = "INSERT INTO build2note (buildid,noteid,time)\n VALUES ('{$this->BuildId}','{$this->Id}','{$this->Time}')";
if (!pdo_query($query)) {
add_last_sql_error("BuildNote:Insert", 0, $this->BuildId);
return false;
}
return true;
}
示例9: GetText
/** Return the text */
function GetText()
{
$query = pdo_query("SELECT text FROM banner WHERE projectid=" . qnum($this->ProjectId));
if (pdo_num_rows($query) == 0) {
return false;
}
$query_array = pdo_fetch_array($query);
$this->Text = $query_array['text'];
if (strlen($this->Text) == 0) {
return false;
}
return $this->Text;
}
示例10: testBuildsRemovedOnSubmission
function testBuildsRemovedOnSubmission()
{
$this->enableAutoRemoveConfigSetting();
$this->setAutoRemoveTimeFrame();
$this->deleteLog($this->logfilename);
$this->startCodeCoverage();
$result = $this->db->query("SELECT id FROM project WHERE name = 'EmailProjectExample'");
$projectid = $result[0]['id'];
// Submit the first build
$rep = dirname(__FILE__) . "/data/EmailProjectExample";
$testxml1 = "{$rep}/1_test.xml";
if (!$this->submission('EmailProjectExample', $testxml1)) {
$this->fail("submission 1 failed");
$this->stopCodeCoverage();
return;
}
// Check that the test is actually there
if (!($query = pdo_query("SELECT name FROM build WHERE projectid='{$projectid}' AND stamp='20090223-0100-Nightly'"))) {
$this->fail("pdo_query returned false");
return 1;
}
$query_array = pdo_fetch_array($query);
if ($query_array[0] != 'Win32-MSVC2009') {
echo $query_array[0];
$this->fail("First build not inserted correctly");
return 1;
}
// Looks like it's a new day
$this->db->query("DELETE FROM dailyupdate WHERE projectid='{$projectid}'");
$testxml2 = "{$rep}/2_test.xml";
if (!$this->submission('EmailProjectExample', $testxml2)) {
$this->fail("submission 2 failed");
$this->stopCodeCoverage();
return 1;
}
// The removal of the builds are done asynchronously so we might need to wait a little bit
// in order for the process to be done
sleep(10);
// seconds
// Check that the first test is gone
if (!($query = pdo_query("SELECT id FROM build WHERE projectid='{$projectid}' AND stamp='20090223-0100-Nightly'"))) {
$this->fail("pdo_query returned false");
return 1;
}
if (pdo_num_rows($query) > 0) {
$this->fail("Auto remove build on submit failed");
return 1;
}
$this->pass("Passed");
$this->stopCodeCoverage();
}
示例11: orsee_session_read
function orsee_session_read($aKey)
{
$query = "SELECT DataValue FROM " . table('http_sessions') . " WHERE SessionID=:aKey";
$pars = array(':aKey' => $aKey);
$result = or_query($query, $pars);
if (pdo_num_rows($result) == 1) {
$r = pdo_fetch_assoc($result);
return $r['DataValue'];
} else {
$query = "INSERT INTO " . table('http_sessions') . " (SessionID, LastUpdated, DataValue)\n VALUES (:aKey, NOW(), '')";
or_query($query, $pars);
return "";
}
}
示例12: Save
/** Save the site information */
function Save()
{
if ($this->OSName != "" || $this->OSPlatform != "" || $this->OSRelease != "" || $this->OSVersion != "") {
if (empty($this->BuildId)) {
return false;
}
// Check if we already have a buildinformation for that build. If yes we just skip it
$query = pdo_query("SELECT buildid FROM buildinformation WHERE buildid=" . qnum($this->BuildId));
add_last_sql_error("BuildInformation Insert", 0, $this->BuildId);
if (pdo_num_rows($query) == 0) {
pdo_query("INSERT INTO buildinformation (buildid,osname,osrelease,osversion,osplatform,compilername,compilerversion) \n VALUES (" . qnum($this->BuildId) . ",'{$this->OSName}','{$this->OSRelease}',\n '{$this->OSVersion}','{$this->OSPlatform}','{$this->CompilerName}','{$this->CompilerVersion}')");
add_last_sql_error("BuildInformation Insert", 0, $this->BuildId);
}
return true;
}
}
示例13: pdo_single_row_query
function pdo_single_row_query($qry)
{
$result = pdo_query($qry);
if (FALSE === $result) {
add_log('error: pdo_query failed: ' . pdo_error(), 'pdo_single_row_query', LOG_ERR);
return array();
}
$num_rows = pdo_num_rows($result);
if (0 !== $num_rows && 1 !== $num_rows) {
add_log('error: at most 1 row should be returned, not ' . $num_rows, 'pdo_single_row_query', LOG_ERR);
add_log('warning: returning the first row anyway even though result ' . 'contains ' . $num_rows . ' rows', 'pdo_single_row_query', LOG_WARNING);
}
$row = pdo_fetch_array($result);
pdo_free_result($result);
return $row;
}
示例14: Insert
public function Insert()
{
if (strlen($this->UpdateId) == 0) {
echo 'BuildUpdateFile:Insert UpdateId not set';
return false;
}
$this->Filename = pdo_real_escape_string($this->Filename);
// Sometimes the checkin date is not found in that case we put the usual date
if ($this->CheckinDate == 'Unknown') {
$this->CheckinDate = '1980-01-01';
}
if (strtotime($this->CheckinDate) === false && is_numeric($this->CheckinDate)) {
$this->CheckinDate = date(FMT_DATETIME, $this->CheckinDate);
} elseif (strtotime($this->CheckinDate) !== false) {
$this->CheckinDate = date(FMT_DATETIME, strtotime($this->CheckinDate));
} else {
$this->CheckinDate = '1980-01-01';
}
$this->Author = pdo_real_escape_string($this->Author);
$this->UpdateId = pdo_real_escape_string($this->UpdateId);
// Check if we have a robot file for this build
$robot = pdo_query('SELECT authorregex FROM projectrobot,build,build2update
WHERE projectrobot.projectid=build.projectid
AND build2update.buildid=build.id
AND build2update.updateid=' . qnum($this->UpdateId) . " AND robotname='" . $this->Author . "'");
if (pdo_num_rows($robot) > 0) {
$robot_array = pdo_fetch_array($robot);
$regex = $robot_array['authorregex'];
preg_match($regex, $this->Log, $matches);
if (isset($matches[1])) {
$this->Author = $matches[1];
}
}
$this->Email = pdo_real_escape_string($this->Email);
$this->Committer = pdo_real_escape_string($this->Committer);
$this->CommitterEmail = pdo_real_escape_string($this->CommitterEmail);
$this->Log = pdo_real_escape_string($this->Log);
$this->Revision = pdo_real_escape_string($this->Revision);
$this->PriorRevision = pdo_real_escape_string($this->PriorRevision);
$query = 'INSERT INTO updatefile (updateid,filename,checkindate,author,email,log,revision,priorrevision,status,committer,committeremail)
VALUES (' . qnum($this->UpdateId) . ",'{$this->Filename}','{$this->CheckinDate}','{$this->Author}','{$this->Email}',\n '{$this->Log}','{$this->Revision}','{$this->PriorRevision}','{$this->Status}','{$this->Committer}','{$this->CommitterEmail}')";
if (!pdo_query($query)) {
add_last_sql_error('BuildUpdateFile Insert', 0, $this->UpdateId);
return false;
}
}
示例15: Save
/** Save a site */
function Save()
{
$name = $this->GetNameFromPlatform($this->Name);
$version = $this->GetNameFromVersion($this->Version);
if (strlen($name) == 0) {
return false;
}
// Check if the name and bits system already exists
$query = pdo_query("SELECT id FROM client_os WHERE name='" . $name . "' AND version='" . $version . "' AND bits='" . $this->Bits . "'");
if (pdo_num_rows($query) == 0) {
$sql = "INSERT INTO client_os (name,version,bits) \n VALUES ('" . $name . "','" . $version . "','" . $this->Bits . "')";
pdo_query($sql);
$this->Id = pdo_insert_id('client_os');
add_last_sql_error("ClientOS::Save()");
} else {
$query_array = pdo_fetch_array($query);
$this->Id = $query_array['id'];
}
}