Esempio n. 1
0
<?php

// init logger
$mylog = MyLog::singleton(MyLog::getLevel("ALL"), "test.log");
// define the autoloader to load classes from the lib folder
function __autoload($className)
{
    if (in_array($className, array("TestConfig", "SmintTestUtils"))) {
        $filename = dirname(__FILE__) . '/' . $className . '.php';
    } else {
        $filename = dirname(__FILE__) . '/../../lib/' . $className . '.php';
    }
    if (file_exists($filename)) {
        require $filename;
    } else {
        throw new Exception('Class "' . $className . '" could not be autoloaded. File not found: ' . $filename);
    }
}
Esempio n. 2
0
File: Track.php Progetto: EQ4/smafe
 protected function queryJobsBySmintFileId()
 {
     // build select statement
     $select_columns = " id, started, finished, status, log ";
     $select_tables = " smafejob_addfile ";
     if (is_null($this->queryFileGUID)) {
         $select_where_clause = " external_key = :external_key ";
     } else {
         $select_where_clause = " guid = :guid ";
     }
     if ($this->collection != $this->apiConfig["databaseconstants"]["defaultCollection"]) {
         $select_where_clause = $select_where_clause . " AND collection_name = :collection_name ";
     }
     $sqlquery = "SELECT " . $select_columns . " FROM " . $select_tables . " WHERE " . $select_where_clause;
     $dbconnection = $this->dbconnection;
     // prepare statement
     $stmt = $dbconnection->prepare($sqlquery);
     // bind paramters
     if ($this->collection != $this->apiConfig["databaseconstants"]["defaultCollection"]) {
         $stmt->bindParam(':collection_name', $this->collection, PDO::PARAM_INT);
     }
     if (is_null($this->queryFileGUID)) {
         $stmt->bindParam(':external_key', $this->queryFileExternal_Key, PDO::PARAM_STR);
     } else {
         $stmt->bindParam(':guid', $this->queryFileGUID, PDO::PARAM_STR);
     }
     $querysuccess = $stmt->execute();
     if ($querysuccess) {
         // fetch the results
         $result = $stmt->fetchAll();
         // log debug message
         MyLog::printWithDuration("Query Database with SQL: {$sqlquery} CollectionId:{$this->collection} GUID: {$this->queryFileGUID} ext_key: {$this->queryFileExternal_Key}", MyLog::getLevel("DEBUG"));
     } else {
         $this->errorMessage = implode(", ", $stmt->errorInfo()) . " querytrackid: {$this->queryFileId} externalTrackid:  {$this->queryFileExternal_Key} queryTrackguid: {$this->queryFileGUID}";
         $result = null;
     }
     return $result;
 }