1
0
mirror of https://github.com/php/doc-de.git synced 2026-03-23 23:02:13 +01:00
Files
archived-doc-de/reference/com/com.xml
2024-06-14 17:01:25 +01:00

160 lines
4.0 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 14767af0f05dffa6fdb9b49e1a1f4e9ca7022a60 Maintainer: nobody Status: ready -->
<!-- Reviewed: yes -->
<!-- Rev-Revision: bd8169a9b15cfa5007f060532c76d5f766cd4adf Reviewer: samesch -->
<reference xml:id="class.com" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
<titleabbrev>com</titleabbrev>
<title>Die Klasse com</title>
<partintro>
<!-- {{{ com intro -->
<section xml:id="com.intro">
&reftitle.intro;
<para>
Mit der Klasse com können Sie ein OLE-kompatibles COM-Objekt erzeugen,
seine Methoden aufrufen und auf seine Eigenschaften zugreifen.
</para>
</section>
<!-- }}} -->
<section xml:id="com.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis class="class">
<ooclass>
<classname>com</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>variant</classname>
</ooclass>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.com')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='com'])">
<xi:fallback/>
</xi:include>
</classsynopsis>
<!-- }}} -->
</section>
<section xml:id="class.com.overloadedmethods">
<title>Überladene Methoden</title>
<para>
Das zurückgegebene Objekt ist überladen, was bedeutet, dass PHP keine
bestimmten Methoden kennt, wie das normalerweise der Fall ist; stattdessen
wird jeder Eigenschafts- oder Methodenzugriff an COM weitergereicht.
</para>
<para>
PHP erkennt Methoden, die per Referenz übergebene Parameter erwarten,
automatisch und wird reguläre PHP-Variablen automatisch in eine Form
umwandeln, die per Referenz übergeben werden kann. Das heißt, dass die
Methode ganz normal aufgerufen werden kann; es ist kein Zusatzaufwand
nötig.
</para>
</section>
<section xml:id="class.com.examples">
<title>com-Beispiele</title>
<para>
<example xml:id="example.com1">
<title>com-Beispiel 1</title>
<programlisting role="php">
<![CDATA[
<?php
// Word starten
$word = new com("word.application") or die("Konnte Word nicht instanziieren");
echo "Word geladen, Version {$word->Version}\n";
// sichtbar machen
$word->Visible = 1;
// ein leeres Dokument öffnen
$word->Documents->Add();
// irgendetwas damit tun
$word->Selection->TypeText("Dies ist ein Test...");
$word->Documents[1]->SaveAs("Nutzloser Test.doc");
// Word schließen
$word->Quit();
// Objekt freigeben
$word = null;
?>
]]>
</programlisting>
</example>
</para>
<para>
<example xml:id="example.com2">
<title>com-Beispiel 2</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = new com("ADODB.Connection") or die("Konnte ADO nicht starten");
$conn->Open("Provider=SQLOLEDB; Data Source=localhost;
Initial Catalog=database; User ID=user; Password=password");
$rs = $conn->Execute("SELECT * FROM sometable"); // Datensatz
$num_columns = $rs->Fields->Count();
echo $num_columns . "\n";
for ($i=0; $i < $num_columns; $i++) {
$fld[$i] = $rs->Fields($i);
}
$rowcount = 0;
while (!$rs->EOF) {
for ($i=0; $i < $num_columns; $i++) {
echo $fld[$i]->value . "\t";
}
echo "\n";
$rowcount++; // Zeilennummer hochzählen
$rs->MoveNext();
}
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
]]>
</programlisting>
</example>
</para>
</section>
</partintro>
&reference.com.entities.com;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->