Example #1
0
/**
 * Create course database :
 * @param string courseDbName partial dbName form course table tu build real DbName
 * @return boolean
 */
function create_course_database($courseDbName)
{
    // Create course database
    if (!get_conf('singleDbEnabled')) {
        claro_sql_query('CREATE DATABASE `' . $courseDbName . '`');
        if (claro_sql_errno() > 0) {
            return claro_failure::set_failure(get_lang('Unable to create course database'));
        }
    }
    return true;
}
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é <moosh@claroline.net>
 * @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
 function queryReturnsResult($sql)
 {
     $result = claro_sql_query($sql);
     if (claro_sql_errno() == 0) {
         if (@mysql_num_rows($result) > 0) {
             @mysql_free_result($result);
             return true;
         } else {
             @mysql_free_result($result);
             return false;
         }
     } else {
         $this->setError();
         return false;
     }
 }
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);
     }
 }