function executeQuery($sql) { claro_sql_query($sql); if (claro_sql_errno() != 0) { $this->setError(); return 0; } return claro_sql_affected_rows(); }
/** * Change the tool installation status in the course * @param int $toolId main tool id * @param string $courseId * @return boolean */ function update_tool_installation_in_course($toolId, $courseId) { $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseId)); $tblCourseToolList = $tbl_cdb_names['tool']; $sql = "UPDATE `{$tblCourseToolList}`\n" . "SET `installed` = 'true'\n" . "WHERE tool_id = " . (int) $toolId; if (claro_sql_query($sql)) { return claro_sql_affected_rows() == 1; } else { false; } }
/** * 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>' : '<0.001') . 'µ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; }