Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : COM and .Net (Windows) : com_event_sink

com_event_sink

Connect events from a COM object to a PHP object (PHP 4 >= 4.2.0, PHP 5)
bool com_event_sink ( variant comobject, object sinkobject [, mixed sinkinterface] )

Example 410. COM event sink example

<?php
class IEEventSinker {
 var
$terminated = false;

 function
ProgressChange($progress, $progressmax) {
   echo
"Download progress: $progress / $progressmax\n";
 }

 function
DocumentComplete(&$dom, $url) {
   echo
"Document $url complete\n";
 }

 function
OnQuit() {
   echo
"Quit!\n";
   
$this->terminated = true;
 }
}
$ie = new COM("InternetExplorer.Application");
// note that you don't need the & for PHP 5!
$sink =& new IEEventSinker();
com_event_sink($ie, $sink, "DWebBrowserEvents2");
$ie->Visible = true;
$ie->Navigate("http://www.php.net");
while(!
$sink->terminated) {
 
com_message_pump(4000);
}
$ie = null;
?>

Code Examples / Notes » com_event_sink

fjortiz

In case someone needs a skeleton sink for ADODB.Connection events:
class ADOConnectionEventSink {
function BeginTransComplete( $translevel, $objerror, $status, $objconn ) {
return 0;
}
function CommitTransComplete( $objerror, $status, $objconn ) {
return 0;
}
function RolbackTransComplete( $objerror, $status, $objconn ) {
return 0;
}
function WillConnect ( $ConnectionString, $userid, $psword, $options, $status, $objconn ) {
return 0;
}
function ConnectComplete ( $objerror, $status, $objconn) {
return 0;
}
function Disconnect( $status, $objConn ) {
return 0;
}
function WillExecute ( $src, $cursortyp, $locktyp, $options, $status, $objcomm, $objrs, $objconn ) {
return 0;
}
function ExecuteComplete ( $recaffected, $objerror, $status, $objcomm, $objrs, $objconn ) {
return 0;
}
function InfoMessage ( $objerror, $status, $objconn) {
return 0;
}
}
// later on...
$db = new COM("ADODB.Connection", NULL, $charPage);
$sink = new ADOConnectionEventSink();
com_event_sink($db, $sink, "ConnectionEvents");
//...


Change Language


Follow Navioo On Twitter
COM
DOTNET
VARIANT
com_addref
com_create_guid
com_event_sink
com_get_active_object
com_get
com_invoke
com_isenum
com_load_typelib
com_load
com_message_pump
com_print_typeinfo
com_propget
com_propput
com_propset
com_release
com_set
variant_abs
variant_add
variant_and
variant_cast
variant_cat
variant_cmp
variant_date_from_timestamp
variant_date_to_timestamp
variant_div
variant_eqv
variant_fix
variant_get_type
variant_idiv
variant_imp
variant_int
variant_mod
variant_mul
variant_neg
variant_not
variant_or
variant_pow
variant_round
variant_set_type
variant_set
variant_sub
variant_xor
eXTReMe Tracker