Example #1
0
 function setError($errmsg = '', $errno = 0)
 {
     if ($errmsg != '') {
         $this->error = $errmsg;
         $this->errno = $errno;
     } else {
         $this->error = claro_sql_error() !== false ? claro_sql_error() : 'Unknown error';
         $this->errno = claro_sql_errno() !== false ? claro_sql_errno() : 0;
     }
     $this->connected = false;
 }
Example #2
0
/**
 * CLAROLINE mySQL query wrapper. It also provides a debug display which works
 * when the CLARO_DEBUG_MODE constant flag is set to on (true)
 *
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @author Christophe Gesché <*****@*****.**>
 * @param  string  $sqlQuery   - the sql query
 * @param  handler $dbHandler  - optional
 * @return handler             - the result handler
 * @deprecated since Claroline 1.9, use Claroline::getDatabase() and new classes
 *  in database/database.lib.php instead
 */
function claro_sql_query($sqlQuery, $dbHandler = '#')
{
    if (claro_debug_mode() && get_conf('CLARO_PROFILE_SQL', false)) {
        $start = microtime();
    }
    if ($dbHandler == '#') {
        $resultHandler = @mysql_query($sqlQuery);
    } else {
        $resultHandler = @mysql_query($sqlQuery, $dbHandler);
    }
    if (claro_debug_mode() && get_conf('CLARO_PROFILE_SQL', false)) {
        static $queryCounter = 1;
        $duration = microtime() - $start;
        $info = 'execution time : ' . ($duration > 0.001 ? '<b>' . round($duration, 4) . '</b>' : '&lt;0.001') . '&#181;s';
        // $info = ( $dbHandler == '#') ? mysql_info() : mysql_info($dbHandler);
        // $info .= ': affected rows :' . (( $dbHandler == '#') ? mysql_affected_rows() : mysql_affected_rows($dbHandler));
        $info .= ': affected rows :' . claro_sql_affected_rows();
        pushClaroMessage('<br />Query counter : <b>' . $queryCounter++ . '</b> : ' . $info . '<br />' . '<code><span class="sqlcode">' . nl2br($sqlQuery) . '</span></code>', claro_sql_errno() ? 'error' : 'sqlinfo');
    }
    if (claro_debug_mode() && claro_sql_errno()) {
        echo '<hr size="1" noshade>' . claro_sql_errno() . ' : ' . claro_sql_error() . '<br>' . '<pre style="color:red">' . $sqlQuery . '</pre>' . (function_exists('claro_html_debug_backtrace') ? claro_html_debug_backtrace() : '') . '<hr size="1" noshade>';
    }
    return $resultHandler;
}
Example #3
0
                 break;
             }
             // visibility
             if (isset($item['isvisible']) && $item['isvisible'] != '') {
                 $item['isvisible'] == "true" ? $visibility = "SHOW" : ($visibility = "HIDE");
             } else {
                 $visibility = 'SHOW';
                 // IMS consider that the default value of 'isvisible' is true
             }
             // finally : insert in learning path
             $sql = "INSERT INTO `" . $TABLELEARNPATHMODULE . "`\n                        (`learnPath_id`, `module_id`, `specificComment`, `rank`, `visibility`, `lock`, `parent`)\n                        VALUES ('" . $tempPathId . "', '" . $insertedModule_id[$i] . "','" . claro_sql_escape(get_block('blockDefaultModuleAddedComment')) . "', " . $rank . ", '" . $visibility . "', 'OPEN', " . $parent . ")";
             $query = claro_sql_query($sql);
             // get the inserted id of the learnPath_module rel to allow 'parent' link in next inserts
             $insertedLPMid[$item['itemIdentifier']]['LPMid'] = claro_sql_insert_id();
             $insertedLPMid[$item['itemIdentifier']]['rank'] = 1;
             if (claro_sql_error()) {
                 $errorFound = true;
                 array_push($errorMsgs, get_lang('Error in SQL statement'));
                 break;
             }
             if (!$errorFound) {
                 array_push($okMsgs, get_lang('Module added : ') . "<i>" . $moduleName . "</i>");
             }
             $i++;
         }
         //foreach
     }
     // if sizeof($manifestData['items'] == 0 )
 }
 // if errorFound
 // last step
Example #4
0
 /**
  * Send the message to member of user list
  *
  * @param array of userId $recipientListID list of user identification
  * @param int $messageId message identification
  */
 private final function sendMessageToUser($recipientListId, $messageId)
 {
     $tableName = get_module_main_tbl(array('im_message_status'));
     //send a message to each user
     foreach ($recipientListId as $currentRecipient) {
         $addInternalMessageSQL = "INSERT INTO `" . $tableName['im_message_status'] . "` " . "(user_id, message_id, is_read, is_deleted) \n" . "values (" . (int) $currentRecipient . "," . (int) $messageId . ",0 , 0)\n";
         if (!claro_sql_query($addInternalMessageSQL)) {
             throw new Exception(claro_sql_errno() . ":" . claro_sql_error());
         }
         $this->addRecipient($messageId, $currentRecipient);
     }
 }