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


PHP pdo_insert_id函数代码示例

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


在下文中一共展示了pdo_insert_id函数的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()');
     }
 }
开发者ID:kitware,项目名称:cdash,代码行数:34,代码来源:clientcmake.php

示例2: Insert

 /** Insert the new user */
 function Insert()
 {
     if (!isset($this->UserId) || $this->UserId < 1) {
         echo "CoverageFile2User:Insert: UserId not set";
         return false;
     }
     if ($this->FullPath == '' || $this->ProjectId < 1) {
         echo "CoverageFile2User:Insert: FullPath or ProjectId not set";
         return false;
     }
     // Check if is already in the database
     if (!$this->Exists()) {
         $this->FileId = $this->GetId();
         if ($this->FileId == 0) {
             $query = "INSERT INTO coveragefilepriority (projectid,fullpath,priority)\n                  VALUES (" . qnum($this->ProjectId) . ",'" . $this->FullPath . "',0)";
             if (!pdo_query($query)) {
                 add_last_sql_error("CoverageFile2User:Insert");
                 return false;
             }
             $this->FileId = pdo_insert_id("coveragefilepriority");
         }
         // Find the new position
         $query = pdo_query("SELECT count(*) AS c FROM coveragefile2user WHERE fileid=" . qnum($this->FileId));
         $query_array = pdo_fetch_array($query);
         $position = $query_array['c'] + 1;
         $query = "INSERT INTO coveragefile2user (userid,fileid,position)\n                VALUES (" . qnum($this->UserId) . "," . qnum($this->FileId) . "," . qnum($position) . ")";
         if (!pdo_query($query)) {
             add_last_sql_error("CoverageFile2User:Insert");
             return false;
         }
         return true;
     }
     return false;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:35,代码来源:coveragefile2user.php

示例3: Insert

 function Insert()
 {
     $text = pdo_real_escape_string($this->Text);
     // Get this->Id from the database if text is already in the label table:
     $this->Id = pdo_get_field_value("SELECT id FROM label WHERE text='{$text}'", 'id', 0);
     // Or, if necessary, insert a new row, then get the id of the inserted row:
     if (0 == $this->Id) {
         $query = "INSERT INTO label (text) VALUES ('{$text}')";
         if (!pdo_query($query)) {
             add_last_sql_error('Label::Insert');
             return false;
         }
         $this->Id = pdo_insert_id('label');
     }
     // Insert relationship records, too, but only for those relationships
     // established by callers. (If coming from test.php, for example, TestId
     // will be set, but none of the others will. Similarly for other callers.)
     $this->InsertAssociation('label2build', 'buildid', $this->BuildId);
     $this->InsertAssociation('label2buildfailure', 'buildfailureid', $this->BuildFailureId);
     $this->InsertAssociation('label2coveragefile', 'buildid', $this->CoverageFileBuildId, 'coveragefileid', $this->CoverageFileId);
     $this->InsertAssociation('label2dynamicanalysis', 'dynamicanalysisid', $this->DynamicAnalysisId);
     $this->InsertAssociation('label2test', 'buildid', $this->TestBuildId, 'testid', $this->TestId);
     // TODO: Implement this:
     //
     //$this->InsertAssociation($this->UpdateFileKey,
     //  'label2updatefile', 'updatefilekey');
     return true;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:28,代码来源:label.php

示例4: 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

示例5: 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

示例6: Insert

 public function Insert()
 {
     if (!$this->BuildId) {
         add_log('BuildId is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         return false;
     }
     if (!$this->Filename) {
         add_log('Filename is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         return false;
     }
     if (!$this->Sha1Sum) {
         add_log('Sha1Sum is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         return false;
     }
     if (!$this->Filesize) {
         add_log('Filesize is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         return false;
     }
     if (empty($this->IsUrl)) {
         $this->IsUrl = 0;
     }
     if (!$this->IsUrl) {
         $filename = pdo_real_escape_string(basename($this->Filename));
     } else {
         $filename = pdo_real_escape_string($this->Filename);
     }
     // Check if the file already exists
     $filequery = pdo_query("SELECT id FROM uploadfile WHERE sha1sum = '" . $this->Sha1Sum . "' AND filename ='{$filename}'");
     if (pdo_num_rows($filequery) == 0) {
         // Insert the file into the database
         $query = "INSERT INTO uploadfile (filename, filesize, sha1sum, isurl) VALUES ('{$filename}','{$this->Filesize}','{$this->Sha1Sum}', '{$this->IsUrl}')";
         if (!pdo_query($query)) {
             add_last_sql_error('Uploadfile::Insert', 0, $this->BuildId);
             return false;
         }
         $this->Id = pdo_insert_id('uploadfile');
     } else {
         $filequery_array = pdo_fetch_array($filequery);
         $this->Id = $filequery_array['id'];
     }
     if (!$this->Id) {
         add_log('No Id', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
         return false;
     }
     if (!pdo_query("INSERT INTO build2uploadfile (fileid, buildid)\n                   VALUES ('{$this->Id}','{$this->BuildId}')")) {
         add_last_sql_error('UploadFile::Insert', 0, $this->BuildId);
         return false;
     }
     return true;
 }
开发者ID:kitware,项目名称:cdash,代码行数:50,代码来源:uploadfile.php

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

示例8: CreateParentBuild

 /** Create a new build as a parent of $this.
  * Assumes many fields have been set prior to calling this function.
  **/
 function CreateParentBuild($numErrors, $numWarnings)
 {
     if ($numErrors < 0) {
         $numErrors = 0;
     }
     if ($numWarnings < 0) {
         $numWarnings = 0;
     }
     // Check if there's an existing build that should be the parent.
     // This would be a standalone build (parent=0) with no subproject
     // that matches our name, site, and stamp.
     $query = "SELECT id FROM build\n              WHERE parentid = 0 AND name = '{$this->Name}' AND\n                    siteid = '{$this->SiteId}' AND stamp = '{$this->Stamp}'";
     $result = pdo_query($query);
     if (pdo_num_rows($result) > 0) {
         $result_array = pdo_fetch_array($result);
         $parentId = $result_array['id'];
         $this->ParentId = $parentId;
         // Mark it as a parent (parentid of -1) and update its tally of
         // build errors & warnings.
         pdo_query("UPDATE build SET parentid = -1 WHERE id = {$parentId}");
         $this->UpdateParentBuild($numErrors, $numWarnings);
     } else {
         // Create the parent build here.  Note how parent builds
         // are indicated by parentid == -1.
         $query = "INSERT INTO build\n        (parentid, siteid, projectid, stamp, name, type, generator,\n         starttime, endtime, submittime, builderrors, buildwarnings)\n        VALUES\n        ('-1','{$this->SiteId}','{$this->ProjectId}','{$this->Stamp}',\n          '{$this->Name}','{$this->Type}','{$this->Generator}',\n          '{$this->StartTime}','{$this->EndTime}','{$this->SubmitTime}',\n          {$numErrors},{$numWarnings})";
         if (!pdo_query($query)) {
             add_last_sql_error("Build Insert Parent", $this->ProjectId, $this->Id);
             return false;
         }
         $parentId = pdo_insert_id("build");
     }
     // Since we just created a parent we should also update any existing
     // builds that should be a child of this parent but aren't yet.
     // This happens when Update.xml is parsed first, because it doesn't
     // contain info about what subproject it came from.
     // TODO: maybe we don't need this any more?
     $query = "UPDATE build SET parentid={$parentId}\n       WHERE parentid=0 AND siteid='{$this->SiteId}' AND\n             name='{$this->Name}' AND stamp='{$this->Stamp}'";
     if (!pdo_query($query)) {
         add_last_sql_error("Build Insert Update Parent", $this->ProjectId, $parentId);
     }
     return $parentId;
 }
开发者ID:josephsnyder,项目名称:CDash,代码行数:45,代码来源:build.php

示例9: Save

 /** Save a job */
 public function Save()
 {
     $sql = "INSERT INTO client_job (scheduleid,osid,siteid,startdate,enddate,status,output,cmakeid,compilerid)\n            VALUES ('" . $this->ScheduleId . "','" . $this->OsId . "','" . $this->SiteId . "','" . $this->StartDate . "','" . $this->EndDate . "','" . $this->Status . "','" . $this->Output . "','" . $this->CMakeId . "','" . $this->CompilerId . "')";
     pdo_query($sql);
     $this->Id = pdo_insert_id('client_job');
     add_last_sql_error('ClientJob::Save');
 }
开发者ID:kitware,项目名称:cdash,代码行数:8,代码来源:clientjob.php

示例10: mysql_insert_id

 function mysql_insert_id($link_identifier = NULL)
 {
     return pdo_insert_id(func_get_args());
 }
开发者ID:jalota16,项目名称:nightcaviar,代码行数:4,代码来源:pdo_mysql.php

示例11: addDailyChanges

/** Add daily changes if necessary */
function addDailyChanges($projectid)
{
    include "cdash/config.php";
    include_once "cdash/common.php";
    include_once "cdash/sendemail.php";
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    pdo_select_db("{$CDASH_DB_NAME}", $db);
    $project_array = pdo_fetch_array(pdo_query("SELECT nightlytime,name,autoremovetimeframe,autoremovemaxbuilds,emailadministrator\n                                              FROM project WHERE id='{$projectid}'"));
    $date = "";
    // now
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array["nightlytime"]);
    $date = gmdate(FMT_DATE, $currentstarttime);
    // Check if we already have it somwhere
    $query = pdo_query("SELECT id FROM dailyupdate WHERE projectid='{$projectid}' AND date='{$date}'");
    if (pdo_num_rows($query) == 0) {
        $cvsauthors = array();
        pdo_query("INSERT INTO dailyupdate (projectid,date,command,type,status)\n               VALUES ({$projectid},'{$date}','NA','NA','0')");
        $updateid = pdo_insert_id("dailyupdate");
        $dates = get_related_dates($project_array["nightlytime"], $date);
        $commits = get_repository_commits($projectid, $dates);
        // Insert the commits
        foreach ($commits as $commit) {
            $filename = $commit['directory'] . "/" . $commit['filename'];
            $checkindate = $commit['time'];
            $author = addslashes($commit['author']);
            $email = '';
            if (isset($commit['email'])) {
                $email = addslashes($commit['email']);
            }
            $log = addslashes($commit['comment']);
            $revision = $commit['revision'];
            $priorrevision = $commit['priorrevision'];
            // Check if we have a robot file for this build
            $robot = pdo_query("SELECT authorregex FROM projectrobot\n                  WHERE projectid=" . qnum($projectid) . " AND robotname='" . $author . "'");
            if (pdo_num_rows($robot) > 0) {
                $robot_array = pdo_fetch_array($robot);
                $regex = $robot_array['authorregex'];
                preg_match($regex, $commit['comment'], $matches);
                if (isset($matches[1])) {
                    $author = addslashes($matches[1]);
                }
            }
            if (!in_array(stripslashes($author), $cvsauthors)) {
                $cvsauthors[] = stripslashes($author);
            }
            pdo_query("INSERT INTO dailyupdatefile (dailyupdateid,filename,checkindate,author,email,log,revision,priorrevision)\n                   VALUES ({$updateid},'{$filename}','{$checkindate}','{$author}','{$email}','{$log}','{$revision}','{$priorrevision}')");
            add_last_sql_error("addDailyChanges", $projectid);
        }
        // end foreach commit
        // If the project has the option to send an email to the author
        if ($project_array['emailadministrator']) {
            sendEmailUnregisteredUsers($projectid, $cvsauthors);
        }
        // Send an email if some expected builds have not been submitting
        sendEmailExpectedBuilds($projectid, $currentstarttime);
        // cleanBuildEmail
        cleanBuildEmail();
        cleanUserTemp();
        // If the status of daily update is set to 2 that means we should send an email
        $query = pdo_query("SELECT status FROM dailyupdate WHERE projectid='{$projectid}' AND date='{$date}'");
        $dailyupdate_array = pdo_fetch_array($query);
        $dailyupdate_status = $dailyupdate_array["status"];
        if ($dailyupdate_status == 2) {
            // Find the groupid
            $group_query = pdo_query("SELECT buildid,groupid FROM summaryemail WHERE date='{$date}'");
            while ($group_array = pdo_fetch_array($group_query)) {
                $groupid = $group_array["groupid"];
                $buildid = $group_array["buildid"];
                // Find if the build has any errors
                $builderror = pdo_query("SELECT count(buildid) FROM builderror WHERE buildid='{$buildid}' AND type='0'");
                $builderror_array = pdo_fetch_array($builderror);
                $nbuilderrors = $builderror_array[0];
                // Find if the build has any warnings
                $buildwarning = pdo_query("SELECT count(buildid) FROM builderror WHERE buildid='{$buildid}' AND type='1'");
                $buildwarning_array = pdo_fetch_array($buildwarning);
                $nbuildwarnings = $buildwarning_array[0];
                // Find if the build has any test failings
                if ($project_emailtesttimingchanged) {
                    $sql = "SELECT count(testid) FROM build2test WHERE buildid='{$buildid}' AND (status='failed' OR timestatus>" . qnum($project_testtimemaxstatus) . ")";
                } else {
                    $sql = "SELECT count(testid) FROM build2test WHERE buildid='{$buildid}' AND status='failed'";
                }
                $nfail_array = pdo_fetch_array(pdo_query($sql));
                $nfailingtests = $nfail_array[0];
                sendsummaryemail($projectid, $groupid, $nbuildwarnings, $nbuilderrors, $nfailingtests);
            }
        }
        pdo_query("UPDATE dailyupdate SET status='1' WHERE projectid='{$projectid}' AND date='{$date}'");
        // Remove the old logs
        include_once "models/errorlog.php";
        $ErrorLog = new ErrorLog();
        $ErrorLog->Clean(10);
        // 10 days
        // Clean the backup directory
        clean_backup_directory();
        // Remove the first builds of the project
        include_once "cdash/autoremove.php";
        removeFirstBuilds($projectid, $project_array["autoremovetimeframe"], $project_array["autoremovemaxbuilds"]);
        removeBuildsGroupwise($projectid, $project_array["autoremovemaxbuilds"]);
//.........这里部分代码省略.........
开发者ID:rpshaw,项目名称:CDash,代码行数:101,代码来源:dailyupdates.php

示例12: do_submit_asynchronous

/** Asynchronous submission */
function do_submit_asynchronous($filehandle, $projectid, $expected_md5 = '')
{
    include 'cdash/config.php';
    include 'cdash/version.php';
    do {
        $filename = $CDASH_BACKUP_DIRECTORY . "/" . mt_rand() . ".xml";
        $fp = @fopen($filename, 'x');
    } while (!$fp);
    fclose($fp);
    unset($fp);
    $outfile = fopen($filename, 'w');
    // Save the file in the backup directory
    while (!feof($filehandle)) {
        $content = fread($filehandle, 8192);
        if (fwrite($outfile, $content) === FALSE) {
            echo "ERROR: Cannot write to file ({$filename})";
            add_log("Cannot write to file ({$filename})", "do_submit_asynchronous", LOG_ERR, $projectid);
            fclose($outfile);
            unset($outfile);
            return;
        }
    }
    fclose($outfile);
    unset($outfile);
    // Sends the file size to the local parser
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists("local/ctestparser.php")) {
        require_once "local/ctestparser.php";
        $localParser = new LocalParser();
        $filesize = filesize($filename);
        $localParser->SetFileSize($projectid, $filesize);
    }
    $md5sum = md5_file($filename);
    $md5error = false;
    echo "<cdash version=\"" . $CDASH_VERSION . "\">\n";
    if ($expected_md5 == '' || $expected_md5 == $md5sum) {
        echo "  <status>OK</status>\n";
        echo "  <message></message>\n";
    } else {
        echo "  <status>ERROR</status>\n";
        echo "  <message>Checksum failed for file.  Expected {$expected_md5} but got {$md5sum}.</message>\n";
        $md5error = true;
    }
    echo "  <md5>{$md5sum}</md5>\n";
    echo "</cdash>\n";
    if ($md5error) {
        add_log("Checksum failure on file: {$filename}", "do_submit_asynchronous", LOG_ERR, $projectid);
        return;
    }
    $bytes = filesize($filename);
    // Insert the filename in the database
    $now_utc = gmdate(FMT_DATETIMESTD);
    pdo_query("INSERT INTO submission (filename,projectid,status,attempts,filesize,filemd5sum,created) " . "VALUES ('" . $filename . "','" . $projectid . "','0','0','{$bytes}','{$md5sum}','{$now_utc}')");
    // Get the ID associated with this submission.  We may need to reference it
    // later if this is a CDash@home (client) submission.
    $submissionid = pdo_insert_id('submission');
    // We find the daily updates
    // If we have php curl we do it asynchronously
    if (function_exists("curl_init") == TRUE) {
        $currentURI = get_server_URI(true);
        $request = $currentURI . "/cdash/dailyupdatescurl.php?projectid=" . $projectid;
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $request);
        curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 1);
        if ($CDASH_USE_HTTPS) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        }
        curl_exec($ch);
        curl_close($ch);
        $clientscheduleid = isset($_GET["clientscheduleid"]) ? pdo_real_escape_numeric($_GET["clientscheduleid"]) : 0;
        if ($clientscheduleid !== 0) {
            pdo_query("INSERT INTO client_jobschedule2submission (scheduleid,submissionid) " . "VALUES ('{$clientscheduleid}','{$submissionid}')");
        }
        // Save submitter IP in the database in the async case, so we have a valid
        // IP at Site::Insert time when processing rather than 'localhost's IP:
        pdo_insert_query("INSERT INTO submission2ip (submissionid, ip) " . "VALUES ('{$submissionid}', '" . $_SERVER['REMOTE_ADDR'] . "')");
        // Call process submissions via cURL.
        trigger_process_submissions($projectid);
    } else {
        add_log("Cannot submit asynchronously: php curl_init function does not exist", "do_submit_asynchronous", LOG_ERR, $projectid);
    }
}
开发者ID:rpshaw,项目名称:CDash,代码行数:85,代码来源:do_submit.php

示例13: Insert

 function Insert()
 {
     if (strlen($this->BuildId) == 0 || !is_numeric($this->BuildId)) {
         echo "BuildUpdate:Insert BuildId not set";
         return false;
     }
     // Remove previous updates
     $query = pdo_query("SELECT updateid FROM build2update WHERE buildid=" . qnum($this->BuildId));
     if (pdo_num_rows($query) == 1) {
         $query_array = pdo_fetch_array($query);
         $updateid = $query_array['updateid'];
         // If the buildupdate and updatefile are not shared we delete them as well
         $query = pdo_query("SELECT buildid FROM build2update WHERE updateid=" . qnum($updateid));
         if (pdo_num_rows($query) == 1) {
             $query = "DELETE FROM buildupdate WHERE id=" . qnum($updateid);
             if (!pdo_query($query)) {
                 add_last_sql_error("BuildUpdate Insert", 0, $this->BuildId);
                 return false;
             }
             $query = "DELETE FROM updatefile WHERE updateid=" . qnum($updateid);
             if (!pdo_query($query)) {
                 add_last_sql_error("BuildUpdate Insert", 0, $this->BuildId);
                 return false;
             }
         }
         $query = "DELETE FROM build2update WHERE buildid=" . qnum($this->BuildId);
         if (!pdo_query($query)) {
             add_last_sql_error("BuildUpdate Insert", 0, $this->BuildId);
             return false;
         }
     }
     $this->StartTime = pdo_real_escape_string($this->StartTime);
     $this->EndTime = pdo_real_escape_string($this->EndTime);
     $this->Command = pdo_real_escape_string($this->Command);
     $this->Type = pdo_real_escape_string($this->Type);
     if (strlen($this->Type) > 4) {
         $this->Type = 'NA';
     }
     $this->Status = pdo_real_escape_string($this->Status);
     $this->Revision = pdo_real_escape_string($this->Revision);
     $this->PriorRevision = pdo_real_escape_string($this->PriorRevision);
     $this->Path = pdo_real_escape_string($this->Path);
     $nfiles = count($this->Files);
     $nwarnings = 0;
     foreach ($this->Files as $file) {
         if ($file->Author == 'Local User' && $file->Revision == -1) {
             $nwarnings++;
         }
     }
     $query = "INSERT INTO buildupdate (starttime,endtime,command,type,status,nfiles,warnings,\n                                       revision,priorrevision,path)\n              VALUES ('{$this->StartTime}','{$this->EndTime}','{$this->Command}',\n                      '{$this->Type}','{$this->Status}',{$nfiles},{$nwarnings},\n                      '{$this->Revision}','{$this->PriorRevision}','{$this->Path}')";
     if (!pdo_query($query)) {
         add_last_sql_error("BuildUpdate Insert", 0, $this->BuildId);
         return false;
     }
     $updateid = pdo_insert_id("buildupdate");
     $query = "INSERT INTO build2update (buildid,updateid)\n              VALUES (" . qnum($this->BuildId) . "," . qnum($updateid) . ")";
     if (!pdo_query($query)) {
         add_last_sql_error("BuildUpdate Insert", 0, $this->BuildId);
         return false;
     }
     // If this is a parent build, make sure that all of its children
     // are also associated with a buildupdate.
     $query = "\n      INSERT INTO build2update (buildid,updateid)\n      SELECT id, '{$updateid}' FROM build\n      LEFT JOIN build2update ON build.id = build2update.buildid\n      WHERE build2update.buildid IS NULL\n      and build.parentid=" . qnum($this->BuildId);
     if (!pdo_query($query)) {
         add_last_sql_error("BuildUpdate Child Insert", 0, $this->BuildId);
         return false;
     }
     foreach ($this->Files as $file) {
         $file->UpdateId = $updateid;
         $file->Insert();
     }
     return true;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:73,代码来源:buildupdate.php

示例14: Insert

 public function Insert()
 {
     if (strlen($this->BuildId) == 0) {
         echo 'DynamicAnalysis::Insert BuildId not set';
         return false;
     }
     $id = '';
     $idvalue = '';
     if ($this->Id) {
         $id = 'id,';
         $idvalue = qnum($this->Id) . ',';
     }
     // Handle log decoding/decompression
     if (strtolower($this->LogEncoding) == 'base64') {
         $this->Log = str_replace(array("\r\n", "\n", "\r"), '', $this->Log);
         $this->Log = base64_decode($this->Log);
     }
     if (strtolower($this->LogCompression) == 'gzip') {
         $this->Log = gzuncompress($this->Log);
     }
     if ($this->Log === false) {
         add_log('Unable to decompress dynamic analysis log', 'DynamicAnalysis::Insert', LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_DYNAMICANALYSIS, $this->Id);
         $this->Log = '';
     }
     $this->Status = pdo_real_escape_string($this->Status);
     $this->Checker = pdo_real_escape_string($this->Checker);
     $this->Name = pdo_real_escape_string($this->Name);
     $path = pdo_real_escape_string(substr($this->Path, 0, 255));
     $fullCommandLine = pdo_real_escape_string(substr($this->FullCommandLine, 0, 255));
     $this->Log = pdo_real_escape_string($this->Log);
     $this->BuildId = pdo_real_escape_string($this->BuildId);
     $query = 'INSERT INTO dynamicanalysis (' . $id . 'buildid,status,checker,name,path,fullcommandline,log)
           VALUES (' . $idvalue . qnum($this->BuildId) . ",'{$this->Status}','{$this->Checker}','{$this->Name}','" . $path . "',\n                      '" . $fullCommandLine . "','{$this->Log}')";
     if (!pdo_query($query)) {
         add_last_sql_error('DynamicAnalysis Insert', 0, $this->BuildId);
         return false;
     }
     if (!$this->Id) {
         $this->Id = pdo_insert_id('dynamicanalysis');
     }
     // Add the defects
     if (!empty($this->Defects)) {
         foreach ($this->Defects as $defect) {
             $defect->DynamicAnalysisId = $this->Id;
             $defect->Insert();
         }
     }
     // Add the labels
     $this->InsertLabelAssociations();
     return true;
 }
开发者ID:kitware,项目名称:cdash,代码行数:51,代码来源:dynamicanalysis.php

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


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