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


PHP pdo_real_escape_string函数代码示例

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


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

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

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

示例3: SetText

 function SetText($text)
 {
     if ($this->ProjectId == -1) {
         echo "Banner::SetText(): no ProjectId specified";
         return false;
     }
     $this->Text = pdo_real_escape_string($text);
     // Check if the project is already
     if ($this->Exists()) {
         // Update the project
         $query = "UPDATE banner SET";
         $query .= " text='" . $this->Text . "'";
         $query .= " WHERE projectid='" . $this->ProjectId . "'";
         if (!pdo_query($query)) {
             add_last_sql_error("Banner:SetText", $this->ProjectId);
             echo $query;
             return false;
         }
     } else {
         $query = "INSERT INTO banner (projectid,text)\n                VALUES (" . qnum($this->ProjectId) . ",'" . $this->Text . "')";
         if (!pdo_query($query)) {
             add_last_sql_error("Banner:SetText", $this->ProjectId);
             echo $query;
             return false;
         }
     }
     return true;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:28,代码来源:banner.php

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

示例5: MD5Exists

 function MD5Exists()
 {
     $md5 = pdo_real_escape_string($this->md5);
     $row = pdo_single_row_query("SELECT buildid FROM buildfile WHERE md5='" . $md5 . "'");
     if (empty($row)) {
         return false;
     }
     return $row[0];
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:9,代码来源:buildfile.php

示例6: Insert

 public function Insert()
 {
     $role = pdo_real_escape_string($this->Role);
     $query = "INSERT INTO test2image (imgid,testid,role)\n              VALUES ('{$this->Id}','{$this->TestId}','{$role}')";
     if (!pdo_query($query)) {
         add_last_sql_error('TestImage Insert');
         return false;
     }
     return true;
 }
开发者ID:kitware,项目名称:cdash,代码行数:10,代码来源:testimage.php

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

示例8: Insert

 function Insert()
 {
     $name = pdo_real_escape_string($this->Name);
     $type = pdo_real_escape_string($this->Type);
     $value = pdo_real_escape_string($this->Value);
     $query = "INSERT INTO testmeasurement (testid,name,type,value)\n              VALUES ('{$this->TestId}','{$name}','{$type}','{$value}')";
     if (!pdo_query($query)) {
         add_last_sql_error("TestMeasurement Insert");
         return false;
     }
     return true;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:12,代码来源:testmeasurement.php

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

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

示例11: Insert

 function Insert()
 {
     if (strlen($this->DynamicAnalysisId) == 0) {
         echo "DynamicAnalysisDefect::Insert DynamicAnalysisId not set";
         return false;
     }
     $this->Type = pdo_real_escape_string($this->Type);
     $this->Value = pdo_real_escape_string($this->Value);
     $this->DynamicAnalysisId = pdo_real_escape_string($this->DynamicAnalysisId);
     $query = "INSERT INTO dynamicanalysisdefect (dynamicanalysisid,type,value)\n              VALUES (" . qnum($this->DynamicAnalysisId) . ",'{$this->Type}','{$this->Value}')";
     if (!pdo_query($query)) {
         add_last_sql_error("DynamicAnalysisDefect Insert");
         return false;
     }
     return true;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:16,代码来源:dynamicanalysisdefect.php

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

示例13: Insert

 public function Insert()
 {
     if (!$this->BuildId) {
         echo 'BuildError::Insert(): BuildId not set<br>';
         return false;
     }
     $text = pdo_real_escape_string($this->Text);
     if (strlen($this->PreContext) == 0) {
         $precontext = 'NULL';
     } else {
         $precontext = "'" . pdo_real_escape_string($this->PreContext) . "'";
     }
     if (strlen($this->PostContext) == 0) {
         $postcontext = 'NULL';
     } else {
         $postcontext = "'" . pdo_real_escape_string($this->PostContext) . "'";
     }
     if (empty($this->SourceLine)) {
         $this->SourceLine = 0;
     }
     if (empty($this->RepeatCount)) {
         $this->RepeatCount = 0;
     }
     $crc32 = 0;
     // Compute the crc32
     if ($this->SourceLine == 0) {
         $crc32 = crc32($text);
         // no need for precontext or postcontext, this doesn't work for parallel build
     } else {
         $crc32 = crc32($text . $this->SourceFile . $this->SourceLine);
         // some warning can be on the same line
     }
     $query = 'INSERT INTO builderror (buildid,type,logline,text,sourcefile,sourceline,precontext,
                                   postcontext,repeatcount,newstatus,crc32)
           VALUES (' . qnum($this->BuildId) . ',' . qnum($this->Type) . ',' . qnum($this->LogLine) . ",'{$text}','{$this->SourceFile}'," . qnum($this->SourceLine) . ',
           ' . $precontext . ',' . $postcontext . ',' . qnum($this->RepeatCount) . ',0,' . qnum($crc32) . ')';
     if (!pdo_query($query)) {
         add_last_sql_error('BuildError Insert', 0, $this->BuildId);
         return false;
     }
     return true;
 }
开发者ID:kitware,项目名称:cdash,代码行数:42,代码来源:builderror.php

示例14: __construct

 public function __construct()
 {
     parent::__construct();
     // Check if the SubProject filter was specified.
     // If so, we won't add SQL clauses for some other filters.
     // Instead we handle them in PHP code via build_survives_filter().
     $this->HasSubProjectsFilter = false;
     $filtercount = pdo_real_escape_numeric(@$_REQUEST['filtercount']);
     for ($i = 1; $i <= $filtercount; ++$i) {
         if (empty($_REQUEST['field' . $i])) {
             continue;
         }
         $field = htmlspecialchars(pdo_real_escape_string($_REQUEST['field' . $i]));
         if ($field === 'subprojects') {
             $this->HasSubProjectsFilter = true;
             break;
         }
     }
     $this->FiltersAffectedBySubProjects = array('buildduration', 'builderrors', 'buildwarnings', 'configureduration', 'configureerrors', 'configurewarnings', 'testsduration', 'testsfailed', 'testsnotrun', 'testspassed', 'testtimestatus');
 }
开发者ID:kitware,项目名称:cdash,代码行数:20,代码来源:filterdataFunctions.php

示例15: Save

 /** Save in the database */
 function Save()
 {
     if (!$this->BuildId || !is_numeric($this->BuildId)) {
         echo "BuildConfigureError::Save(): BuildId not set";
         return false;
     }
     if (!$this->Type || !is_numeric($this->Type)) {
         echo "BuildConfigureError::Save(): Type not set";
         return false;
     }
     if (!$this->Exists()) {
         $text = pdo_real_escape_string($this->Text);
         $query = "INSERT INTO configureerror (buildid,type,text)\n                VALUES (" . qnum($this->BuildId) . "," . qnum($this->Type) . ",'{$text}')";
         if (!pdo_query($query)) {
             add_last_sql_error("BuildConfigureError:Save", 0, $this->BuildId);
             return false;
         }
     }
     return true;
 }
开发者ID:rpshaw,项目名称:CDash,代码行数:21,代码来源:buildconfigureerror.php


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