当前位置: 首页>>代码示例>>PHP>>正文


PHP pdo_fetch_array函数代码示例

本文整理汇总了PHP中pdo_fetch_array函数的典型用法代码示例。如果您正苦于以下问题:PHP pdo_fetch_array函数的具体用法?PHP pdo_fetch_array怎么用?PHP pdo_fetch_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pdo_fetch_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copy_build_table

/**
 * Copy table rows by assigning them a new buildid.
 **/
function copy_build_table($old_buildid, $new_buildid, $table)
{
    $result = pdo_query("SELECT * FROM {$table} WHERE buildid={$old_buildid}");
    while ($result_array = pdo_fetch_array($result)) {
        // Remove the old buildid from our SELECT results, as we will be replacing
        // that with the new buildid.
        unset($result_array['buildid']);
        // Generate an INSERT query by listing all of the table columns
        // and their values.  This is slightly complicated by the fact that
        // our array has both string and integer keys.
        $keys = array();
        $values = array();
        foreach ($result_array as $key => $val) {
            if (!is_int($key)) {
                $keys[] = $key;
                $values[] = $val;
            }
        }
        $insert_query = "INSERT INTO {$table} (buildid,";
        $insert_query .= implode(",", $keys) . ")";
        $insert_query .= " VALUES ('{$new_buildid}','";
        $insert_query .= implode("','", $values) . "')";
        pdo_query($insert_query);
    }
}
开发者ID:rpshaw,项目名称:CDash,代码行数:28,代码来源:copy_build_data.php

示例2: 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);
 }
开发者ID:josephsnyder,项目名称:CDash,代码行数:31,代码来源:api_project.php

示例3: GetNumberOfFailures

 /** Get the number of tests that are failing */
 function GetNumberOfFailures($checktesttiming, $testtimemaxstatus)
 {
     if (!$this->BuildId) {
         echo "BuildTest::GetNumberOfFailures(): BuildId not set";
         return false;
     }
     $sql = "SELECT testfailed,testnotrun,testtimestatusfailed FROM build WHERE id=" . qnum($this->BuildId);
     $query = pdo_query($sql);
     if (!$query) {
         add_last_sql_error("BuildTest:GetNumberOfFailures", 0, $this->BuildId);
         return false;
     }
     $nfail_array = pdo_fetch_array($query);
     $sumerrors = 0;
     if ($nfail_array['testfailed'] > 0) {
         $sumerrors += $nfail_array['testfailed'];
     }
     if ($nfail_array['testnotrun'] > 0) {
         $sumerrors += $nfail_array['testnotrun'];
     }
     // Find if the build has any test failings
     if ($checktesttiming) {
         if ($nfail_array['testtimestatusfailed'] > 0) {
             $sumerrors += $nfail_array['testtimestatusfailed'];
         }
     }
     return $sumerrors;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:29,代码来源:buildtest.php

示例4: GetAuthors

 /** Get all the authors of a file */
 public function GetAuthors($filename, $onlylast = false)
 {
     if (!$this->ProjectId) {
         echo 'DailyUpdate::GetAuthors(): ProjectId is not set<br>';
         return false;
     }
     // Check if the note already exists
     $filename = pdo_real_escape_string($filename);
     // Remove
     if (substr($filename, 0, 2) == './') {
         $filename = substr($filename, 2);
     }
     $sql = '';
     if ($onlylast) {
         $sql = ' ORDER BY dailyupdate.id DESC LIMIT 1';
     }
     $query = pdo_query('SELECT DISTINCT up.userid,dailyupdate.id FROM user2project AS up,user2repository AS ur,dailyupdatefile,dailyupdate
                     WHERE dailyupdatefile.dailyupdateid=dailyupdate.id
                     AND dailyupdate.projectid=up.projectid
                     AND ur.credential=dailyupdatefile.author
                     AND up.projectid=' . qnum($this->ProjectId) . '
                     AND up.userid=ur.userid
                     AND (ur.projectid=0 OR ur.projectid=' . qnum($this->ProjectId) . ")\n                        AND dailyupdatefile.filename LIKE '%" . $filename . "'" . $sql);
     if (!$query) {
         add_last_sql_error('DailyUpdate GetAuthors', $this->ProjectId);
         return false;
     }
     $authorids = array();
     while ($query_array = pdo_fetch_array($query)) {
         $authorids[] = $query_array['userid'];
     }
     return $authorids;
 }
开发者ID:kitware,项目名称:cdash,代码行数:34,代码来源:dailyupdate.php

示例5: 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;
}
开发者ID:rpshaw,项目名称:CDash,代码行数:60,代码来源:viewChanges.php

示例6: 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;
 }
开发者ID:josephsnyder,项目名称:CDash,代码行数:60,代码来源:api_coverage.php

示例7: 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;
     }
 }
开发者ID:kitware,项目名称:cdash,代码行数:58,代码来源:test_testhistory.php

示例8: Exists

 /** Return if exists */
 public function Exists()
 {
     $query = pdo_query("SELECT count(*) AS c FROM test2image WHERE imgid='" . $this->Id . "' AND testid='" . $this->TestId . "' AND role='" . $this->Role . "'");
     $query_array = pdo_fetch_array($query);
     if ($query_array['c'] > 0) {
         return true;
     }
     return false;
 }
开发者ID:kitware,项目名称:cdash,代码行数:10,代码来源:testimage.php

示例9: 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;
}
开发者ID:rpshaw,项目名称:CDash,代码行数:10,代码来源:viewDynamicAnalysisFile.php

示例10: Exists

 /** Return if exists */
 function Exists()
 {
     $query = pdo_query("SELECT count(*) AS c FROM banner WHERE projectid=" . qnum($this->ProjectId));
     $query_array = pdo_fetch_array($query);
     if ($query_array['c'] > 0) {
         return true;
     }
     return false;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:10,代码来源:banner.php

示例11: Exists

 /** Return if exists */
 function Exists()
 {
     $query = pdo_query("SELECT count(*) AS c FROM configureerrordiff WHERE buildid=" . qnum($this->BuildId));
     $query_array = pdo_fetch_array($query);
     if ($query_array['c'] > 0) {
         return true;
     }
     return false;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:10,代码来源:buildconfigureerrordiff.php

示例12: GetSite

 /** Get Site */
 public function GetSite()
 {
     if (!$this->Id) {
         add_log('ClientJob::GetSite', 'Id not set');
         return;
     }
     $sys = pdo_query('SELECT siteid FROM client_job WHERE id=' . qnum($this->Id));
     $row = pdo_fetch_array($sys);
     return $row[0];
 }
开发者ID:kitware,项目名称:cdash,代码行数:11,代码来源:clientjob.php

示例13: GetNumberOfErrors

 /** Find how many dynamic analysis tests were failed or notrun status */
 public function GetNumberOfErrors()
 {
     if (strlen($this->BuildId) == 0) {
         echo 'DynamicAnalysis::GetNumberOfErrors BuildId not set';
         return false;
     }
     $query = 'SELECT count(*) FROM dynamicanalysis WHERE buildid=' . qnum($this->BuildId) . " AND status IN ('notrun','failed')";
     $errorcount = pdo_query($query);
     $error_array = pdo_fetch_array($errorcount);
     return $error_array[0];
 }
开发者ID:kitware,项目名称:cdash,代码行数:12,代码来源:dynamicanalysis.php

示例14: 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;
 }
开发者ID:kitware,项目名称:cdash,代码行数:53,代码来源:buildnote.php

示例15: 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;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:52,代码来源:buildnote.php


注:本文中的pdo_fetch_array函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。