Exemplo n.º 1
0
 protected function _execPS()
 {
     // execute prepared statement
     if ($this->sqliteVers < 3 || !$this->preparedStatement) {
         return false;
     }
     if (!parent::_execPS()) {
         return false;
     }
     // _preparePS is called here if necessary
     //echo 'SQLite _execPS()<br/>';
     $tm_start = microtime(true);
     try {
         $r = $this->preparedStatement->execute();
     } catch (Exception $ex) {
         return false;
     }
     echo "<span style='color:silver'>==TIME</span>::" . round((microtime(true) - $tm_start) * 10000) * 0.1 . " for sqlite prepared execute<br/>";
     //echo 'SQLite prepared exec result:';var_dump($r);echo '<br/>';
     if (!$r) {
         // query didn't succeed
         $this->_onQueryError();
         return false;
     }
     if (!$this->modePDO) {
         // direct SQLite
         return $r;
         // result type is SQLite3Result
     } else {
         // PDO
         return $this->preparedStatement;
         // result type is PDOStatement
     }
 }
Exemplo n.º 2
0
function __final()
{
    // mostly debug output
    global $a_tm, $tm_start_all, $oeScriptStartTime, $oephpOutputToBuffer, $oephpDebugMode, $oephpDebugModeShowExpanded, $dynManager, $oeLoginSQLite_LocalWebServer, $oeHeaderInlineCode, $oeStartBodyInlineCode;
    // show time performance:
    $a_tm['====ALL'] = round((microtime(true) - $tm_start_all) * 1000);
    foreach ($a_tm as $key => $value) {
        $a_tm[$key] = round($a_tm[$key]);
    }
    echo '<span style="font-size:7px;">';
    var_dump($a_tm);
    echo '</span>';
    // add security token - hidden form element
    $pageSerial = $dynManager->GetDataByFullID('AutoVals.PageID', 0);
    OEDynUtils::AddHiddenSecurityToken($oeStartBodyInlineCode, $pageSerial);
    $oeStartBodyInlineCode .= "\n";
    $oeDBAdminToolCode = '';
    // Link to db editor - only in local mode:
    if (OESQLBase::isLocalSQLite() && isset($dynManager->JSData['PageRelPath'])) {
        $paregelpath = $dynManager->JSData['PageRelPath'];
        $dbadminerlink = $paregelpath . 'WEFiles/Server/DB/dbadmin/phpliteadmin.php';
        // sqlite administrator
        $oeDBAdminToolCode = "DB admin tool (for local test DB only!): <a href='{$dbadminerlink}?db=../../../{$oeLoginSQLite_LocalWebServer['dbname']}' target='_blanc'>PHPLiteAdmin</a><br/>";
        echo '<br/>' . $oeDBAdminToolCode;
    }
    $oeMailEmulationCode = OEDynUtils::DebugMailEmulation();
    if ($oeMailEmulationCode) {
        echo $oeMailEmulationCode;
    }
    echo '</div>';
    if ($oephpOutputToBuffer || !$oephpDebugMode) {
        $oephpDebugBuff = '';
        if ($oephpDebugMode) {
            // debug mode - keep all output
            $oephpDebugBuff = ob_get_contents();
        } else {
            if (OESQLBase::isLocalSQLite()) {
                // local previsualisation mode - keep only tool output
                if ($oeDBAdminToolCode) {
                    $oephpDebugBuff .= '<div id="oephpDebugDiv">' . $oeDBAdminToolCode . '</div>';
                }
                if ($oeMailEmulationCode) {
                    $oephpDebugBuff .= $oeMailEmulationCode;
                }
            }
        }
        if ($oephpDebugBuff) {
            $oeStartBodyInlineCode = !isset($oeStartBodyInlineCode) ? $oephpDebugBuff : $oeStartBodyInlineCode . $oephpDebugBuff;
            $oeDebugJSCode = '';
            $oeDebugJSCode .= "<script> \$(document).ready(function() { \n";
            // style='text-decoration:blink;-webkit-animation: blink 1s steps(5, start) infinite;'
            if ($oeMailEmulationCode) {
                $oeDebugJSCode .= <<<HDEND
\t\t\t\t\t\$('body').prepend("<div id='oephpMailEmulationClick' style='cursor:pointer;background-color:#D0E8FF;color:black;font-size:12px;position:absolute;z-index:10000000;top:16px;width:100%;'>Local Debug (dbl-click to expand): <b>Mailbox (Boite Mail)</b> <b>emulation</b></div>");
\t\t\t\t\t\$('#oephpMailEmulationClick').prepend(\$('#oeDebugMailEmulation'));
\t\t\t\t\t\$('#oephpMailEmulationClick').dblclick(function(){ \$('#oeDebugMailEmulation').toggle(); });
\t\t\t\t\t\$('#oeDebugMailEmulation').hide();
HDEND;
            }
            $oeScriptTime = round((microtime(true) - $oeScriptStartTime) * 1000);
            $oeScriptTime = $a_tm['require All DynEngine'] . '+' . ($oeScriptTime - $a_tm['require All DynEngine']) . '=' . $oeScriptTime;
            $oeDebugJSCode .= <<<HDEND
\t\t\t\t\t\$('body').prepend("<div id='oephpDebugClick' style='cursor:pointer;background-color:#F0F0F0;color:black;font-size:12px;position:absolute;z-index:10000001;top:0px;width:100%'>Local Debug (dbl-click to expand): <b style='text-decoration:none;'>PHP + DB</b>&nbsp;&nbsp;<i>(script load+run time: <b>{$oeScriptTime}</b>ms)</i></div>");
\t\t\t\t\t\$('#oephpDebugClick').prepend(\$('#oephpDebugDiv'));
\t\t\t\t\t\$('#oephpDebugClick').dblclick(function(){ \$('#oephpDebugDiv').toggle(); });
\t\t\t\t\t\$('#oephpDebugClick').fadeTo('slow', 0.25).fadeTo('slow', 1.0);
\t\t\t\t\t\$('#oephpMailEmulationClick').fadeTo('slow', 0.25).fadeTo('slow', 1.0);
HDEND;
            if (!$oephpDebugModeShowExpanded) {
                $oeDebugJSCode .= "\n \$('#oephpDebugDiv').hide(); \n";
            }
            $oeDebugJSCode .= "\n});</script>";
            $oeHeaderInlineCode = !isset($oeHeaderInlineCode) ? $oeDebugJSCode : $oeDebugJSCode . $oeHeaderInlineCode;
        }
        ob_end_clean();
        // clear all php output
    }
}
Exemplo n.º 3
0
 function RunDBRequests()
 {
     //echo "SQL request pack:";var_dump($this->RequestPack);
     //var_dump(OESQLBase::SQLInstance());
     //$tm = microtime(true);
     $arResults = OESQLBase::SQLInstance()->runSQLPack($this->RequestPack);
     //!!fix same name ??
     //echo "<span style='color:blue'>==TIME</span>::".(round((microtime(true) - $tm)*10000)*0.1)." for runSQLPack<br/>";
     $fusionContainer = null;
     $cName = $this->_ResultName();
     if (!empty($arResults)) {
         foreach ($arResults as &$container) {
             //var_dump($container);
             $container->SetName($cName);
             // Manage primary keys columns with non-standard names:
             if (isset($this->Params['PKeys'])) {
                 foreach ($this->Params['PKeys'] as $pkey) {
                     $container->SetPrimaryKey($pkey);
                 }
             }
             if (!$fusionContainer) {
                 $fusionContainer =& $container;
             } else {
                 // merge containers into one:
                 $fusionContainer->AddFromContainer($container);
             }
             //break;//!! now only one container per action //!!fix merge several containers
         }
         unset($container);
         // break the reference (see php manual)
     }
     //echo $fusionContainer->Name.':';var_dump($fusionContainer->Values);
     //foreach ($arResults as $tr) {echo $tr->toJSON(); }
     $this->Manager->addContainer($fusionContainer);
     //echo "Request completed, results:";//var_dump($this->Manager->dataContainers[3]);
 }