當前位置: 首頁>>代碼示例>>PHP>>正文


PHP eZDB::setErrorHandling方法代碼示例

本文整理匯總了PHP中eZDB::setErrorHandling方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZDB::setErrorHandling方法的具體用法?PHP eZDB::setErrorHandling怎麽用?PHP eZDB::setErrorHandling使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZDB的用法示例。


在下文中一共展示了eZDB::setErrorHandling方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

    /**
     * Main method: infinite method that monitors queued objects, and starts
     * the publishinbg processes if allowed
     *
     * @return void
     */
    public function run()
    {
        // use DB exceptions so that errors can be fully handled
        eZDB::setErrorHandling( eZDB::ERROR_HANDLING_EXCEPTIONS );

        $this->cleanupDeadProcesses();

        while ( $this->canProcess )
        {
            try {
                /**
                 * @var ezpContentPublishingProcess
                 */
                $publishingItem = call_user_func( array( $this->queueReader, 'next' ) );
                if ( $publishingItem !== false )
                {
                    if ( !$this->isSlotAvailable() )
                    {
                        $this->out->write( "No slot is available", 'async.log' );
                        sleep ( 1 );
                        continue;
                    }
                    else
                    {
                        $this->out->write( "Processing item #" . $publishingItem->attribute( 'ezcontentobject_version_id' ), 'async.log' );
                        $pid = $publishingItem->publish();
                        pcntl_signal( SIGINT, $this->signalHandler );
                        $this->currentJobs[$pid] = $publishingItem;

                        // In the event that a signal for this pid was caught before we get here, it will be in our
                        // signalQueue array
                        // Process it now as if we'd just received the signal
                        if( isset( $this->signalQueue[$pid] ) )
                        {
                            $this->out->write( "found $pid in the signal queue, processing it now" );
                            $this->childSignalHandler( SIGCHLD, $pid, $this->signalQueue[$pid] );
                            unset( $this->signalQueue[$pid] );
                        }
                    }
                }
                else
                {
                    sleep( $this->sleepInterval );
                }
            } catch ( eZDBException $e ) {
                $this->out->write( "Database error #" . $e->getCode() . ": " . $e->getMessage() );
                // force the DB connection closed so that it is recreated
                try {
                    $db = eZDB::instance();
                    $db->close();
                    $db = null;
                    eZDB::setInstance( null );
                } catch( eZDBException $e ) {
                    // Do nothing, this will be retried until the DB is back up
                }
                sleep( 1 );
            }
        }
    }
開發者ID:sushilbshinde,項目名稱:ezpublish-study,代碼行數:65,代碼來源:ezpcontentpublishingqueueprocessor.php


注:本文中的eZDB::setErrorHandling方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。