<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/19/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aparup</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/19/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aparup"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/Special:Contributions/Aparup"/>
	<updated>2026-04-17T10:40:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Automated_course_backup&amp;diff=84143</id>
		<title>Automated course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Automated_course_backup&amp;diff=84143"/>
		<updated>2011-07-27T03:05:12Z</updated>

		<summary type="html">&lt;p&gt;Aparup: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Location: &#039;&#039;Administration &amp;gt; Courses &amp;gt; Backups&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The backups page enables administrators to configure automated course backups and a backup schedule. &lt;br /&gt;
Automated course backups runs the same functions as individual [[Course backup|course backups]]. It&#039;s a good idea to schedule backups for when your server isn&#039;t usually busy. Running the backup tool over all the courses can be processor-intensive, so you shouldn&#039;t run it when there are a lot of students trying to access the server. You should always alert users with an announcement on the first page that if they log on during the backup hours they may notice a decrease in performance.  &lt;br /&gt;
&lt;br /&gt;
In order to make scheduled backups, you have to set up CRON to run periodically. Please refer to the [[Cron|cron instructions]].&lt;br /&gt;
&lt;br /&gt;
==Setting a backup schedule==&lt;br /&gt;
&lt;br /&gt;
To set the backup schedule:&lt;br /&gt;
#Click the Active checkbox. This turns on the automated backup system.&lt;br /&gt;
#Click the days of the week to run the backup.&lt;br /&gt;
#Set the execution time for the backup process. For most servers, early morning will be the best time.  Keep in mind the time zone your server is using.&lt;br /&gt;
#Set the &amp;quot;Save to...&amp;quot; path. If you can, choose a backup path on another machine or on a different drive than the one Moodle is on. You don’t want to lose your backups at the same time you lose your Moodle site if the drive fails. If you leave the field blank, then backup zip files will be saved in the backup folder of each course files folder. On a Linux server the path might look like: /home/(your user or domain)/public_html/archive/ or if it&#039;s below the publicly accessible folders: /home/(your user or domain)/archive/ if the path is not recognized a red X is shown after saving, otherwise a green check.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
Once you&#039;ve set up your backup schedule, Moodle will automatically create archives of all the courses on the server at the time you specified. Once the backup is complete, Moodle will send you an email describing the status of the backup.&lt;br /&gt;
&lt;br /&gt;
Note: From 1.6 onwards, course backups automatically skip courses which are unavailable to students and have not been changed in the last month.&lt;br /&gt;
&lt;br /&gt;
==Course versus site backups==&lt;br /&gt;
&lt;br /&gt;
*Automated course backups are more expensive in terms of time and CPU usage. The recovery time to have your site running again is longer. &lt;br /&gt;
*Course backups are useful for obtaining &amp;quot;fresh&amp;quot; copies of courses to be re-used or distributed individually, however they should never be used as a primary backup system (unless your hosting doesn&#039;t allow the preferred [[Site backup|site backups]]). &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Backup and restore FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Backup]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Ikastaroen_segurtasun-kopia_automatikoa]]&lt;br /&gt;
[[fr:Sauvegarde (administrateur)]]&lt;br /&gt;
[[ja:自動コースバックアップ]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Parent_role&amp;diff=82696</id>
		<title>Parent role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Parent_role&amp;diff=82696"/>
		<updated>2011-04-11T09:22:14Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Role assignment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The role of &#039;&#039;&#039;Parent&#039;&#039;&#039; may be used to provide parents/mentors/tutors with permission to view certain information, such as activity reports, grades, blog entries and forum posts, about their children/mentees/tutees.&lt;br /&gt;
&lt;br /&gt;
==Role set-up==&lt;br /&gt;
&lt;br /&gt;
#Access &#039;&#039;Administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
#Click the button &amp;quot;Add a new role&amp;quot;&lt;br /&gt;
#Give the role a name e.g. Parent, short name and description&lt;br /&gt;
#From 2.0 onwards, We need to check the &#039;User&#039; checkbox in &#039;Context types where this role may be assigned&#039;&lt;br /&gt;
#Change [[Capabilities/moodle/user:viewdetails|moodle/user:viewdetails]] to &#039;&#039;allow&#039;&#039; - this item is listed within the &#039;Course&#039; section in 1.9&lt;br /&gt;
#Change any/all of the following capabilities to &#039;&#039;allow&#039;&#039;&lt;br /&gt;
#*[[Capabilities/moodle/user:readuserblogs|moodle/user:readuserblogs]] - to read the child&#039;s blog entries&lt;br /&gt;
#*[[Capabilities/moodle/user:readuserposts|moodle/user:readuserposts]] - to read the child&#039;s forum posts&lt;br /&gt;
#*[[Capabilities/moodle/user:viewuseractivitiesreport|moodle/user:viewuseractivitiesreport]] - to view the child&#039;s activity reports and grades&lt;br /&gt;
#*[[Capabilities/moodle/user:editprofile|moodle/user:editprofile]] - to edit the child&#039;s profile&lt;br /&gt;
#Click the button &amp;quot;Add a new role&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Role assignment==&lt;br /&gt;
&lt;br /&gt;
#Access the child&#039;s profile page and click on the Roles tab i.e. assign the role in the user context , &#039;Profile settings for [username]&#039; &amp;gt; &#039;Roles&#039; &amp;gt;&#039;Assign roles relative to this user&#039;&lt;br /&gt;
#Choose the role to assign i.e. Parent&lt;br /&gt;
#Select the parent in the potential users list, and use the left-facing arrow button to add it to the existing users list&lt;br /&gt;
The same parent may be assigned to several children.&lt;br /&gt;
===Adding multiple role assignments at once===&lt;br /&gt;
(if you are interested in assigning several parent roles &#039;&#039;en masse&#039;&#039; read the discussion at http://moodle.org/mod/forum/discuss.php?d=70539#p345127)&lt;br /&gt;
&lt;br /&gt;
==Mentees block==&lt;br /&gt;
{{Moodle 1.8}}&lt;br /&gt;
The [[Mentees block]] provides a parent with quick access to their child&#039;s profile page via a link on the site front page.&lt;br /&gt;
#On the site front page click &amp;quot;Turn editing on&amp;quot;&lt;br /&gt;
#Choose Mentees from the Add a block drop-down menu&lt;br /&gt;
#If required, give the Mentees block a title by following the block configuration/edit link&lt;br /&gt;
&lt;br /&gt;
==Viewing activity reports==&lt;br /&gt;
&lt;br /&gt;
If the capability [[Capabilities/moodle/user:viewuseractivitiesreport|moodle/user:viewuseractivitiesreport]] is set to &#039;&#039;allow&#039;&#039; then a parent/mentee may view their student&#039;s activity reports and grades via the student&#039;s Profile.   &lt;br /&gt;
&lt;br /&gt;
On the main Profile page, there will be a list of courses.  Clicking on a course title will select that course.  Then, under the Activities tab, the various report and grades sub-tabs will display information relevant to the selected course.   You can easily change which course you are reviewing by selecting another one on the main Profile tab.&lt;br /&gt;
&lt;br /&gt;
One small hack that can make the course list a bit more readable, especially for long course lists, is to change the format to a vertical list:&lt;br /&gt;
&lt;br /&gt;
* Edit the moodle/user/view.php file and look for these lines (around line 349 in my 1.9.9 installation):&lt;br /&gt;
&amp;lt;code php&amp;gt;. format_string($mycourse-&amp;gt;fullname) . &amp;quot;&amp;lt;/a&amp;gt;, &amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
$courselisting .= format_string($mycourse-&amp;gt;fullname) . &amp;quot;, &amp;quot;;&amp;lt;/code&amp;gt;&lt;br /&gt;
* and change that to :&lt;br /&gt;
&amp;lt;code php&amp;gt;. format_string($mycourse-&amp;gt;fullname) . &amp;quot;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
$courselisting .= format_string($mycourse-&amp;gt;fullname) . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Then save&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Manage roles]] - including testing a new role&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=57812 Create a Parent of a student role] forum discussion &lt;br /&gt;
*[http://www.youtube.com/watch?v=-49YrtjMTTo Setting up a Parent Role video]&lt;br /&gt;
*[http://www.youtube.com/watch?v=P23GT2peLZI Parent Signing in on Moodle video]&lt;br /&gt;
&lt;br /&gt;
[[Category:Roles]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Guraso_rola]]&lt;br /&gt;
[[fr:Rôle Parent]]&lt;br /&gt;
[[ja:親ロール]]&lt;br /&gt;
[[de:Eltern-Rolle]]&lt;br /&gt;
[[nl:Ouder Rol]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Parent_role&amp;diff=82695</id>
		<title>Parent role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Parent_role&amp;diff=82695"/>
		<updated>2011-04-11T09:09:58Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Role set-up */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The role of &#039;&#039;&#039;Parent&#039;&#039;&#039; may be used to provide parents/mentors/tutors with permission to view certain information, such as activity reports, grades, blog entries and forum posts, about their children/mentees/tutees.&lt;br /&gt;
&lt;br /&gt;
==Role set-up==&lt;br /&gt;
&lt;br /&gt;
#Access &#039;&#039;Administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
#Click the button &amp;quot;Add a new role&amp;quot;&lt;br /&gt;
#Give the role a name e.g. Parent, short name and description&lt;br /&gt;
#From 2.0 onwards, We need to check the &#039;User&#039; checkbox in &#039;Context types where this role may be assigned&#039;&lt;br /&gt;
#Change [[Capabilities/moodle/user:viewdetails|moodle/user:viewdetails]] to &#039;&#039;allow&#039;&#039; - this item is listed within the &#039;Course&#039; section in 1.9&lt;br /&gt;
#Change any/all of the following capabilities to &#039;&#039;allow&#039;&#039;&lt;br /&gt;
#*[[Capabilities/moodle/user:readuserblogs|moodle/user:readuserblogs]] - to read the child&#039;s blog entries&lt;br /&gt;
#*[[Capabilities/moodle/user:readuserposts|moodle/user:readuserposts]] - to read the child&#039;s forum posts&lt;br /&gt;
#*[[Capabilities/moodle/user:viewuseractivitiesreport|moodle/user:viewuseractivitiesreport]] - to view the child&#039;s activity reports and grades&lt;br /&gt;
#*[[Capabilities/moodle/user:editprofile|moodle/user:editprofile]] - to edit the child&#039;s profile&lt;br /&gt;
#Click the button &amp;quot;Add a new role&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Role assignment==&lt;br /&gt;
&lt;br /&gt;
#Access the child&#039;s profile page and click on the Roles tab i.e. assign the role in the user context&lt;br /&gt;
#Choose the role to assign i.e. Parent&lt;br /&gt;
#Select the parent in the potential users list, and use the left-facing arrow button to add it to the existing users list&lt;br /&gt;
The same parent may be assigned to several children.&lt;br /&gt;
===Adding multiple role assignments at once===&lt;br /&gt;
(if you are interested in assigning several parent roles &#039;&#039;en masse&#039;&#039; read the discussion at http://moodle.org/mod/forum/discuss.php?d=70539#p345127)&lt;br /&gt;
&lt;br /&gt;
==Mentees block==&lt;br /&gt;
{{Moodle 1.8}}&lt;br /&gt;
The [[Mentees block]] provides a parent with quick access to their child&#039;s profile page via a link on the site front page.&lt;br /&gt;
#On the site front page click &amp;quot;Turn editing on&amp;quot;&lt;br /&gt;
#Choose Mentees from the Add a block drop-down menu&lt;br /&gt;
#If required, give the Mentees block a title by following the block configuration/edit link&lt;br /&gt;
&lt;br /&gt;
==Viewing activity reports==&lt;br /&gt;
&lt;br /&gt;
If the capability [[Capabilities/moodle/user:viewuseractivitiesreport|moodle/user:viewuseractivitiesreport]] is set to &#039;&#039;allow&#039;&#039; then a parent/mentee may view their student&#039;s activity reports and grades via the student&#039;s Profile.   &lt;br /&gt;
&lt;br /&gt;
On the main Profile page, there will be a list of courses.  Clicking on a course title will select that course.  Then, under the Activities tab, the various report and grades sub-tabs will display information relevant to the selected course.   You can easily change which course you are reviewing by selecting another one on the main Profile tab.&lt;br /&gt;
&lt;br /&gt;
One small hack that can make the course list a bit more readable, especially for long course lists, is to change the format to a vertical list:&lt;br /&gt;
&lt;br /&gt;
* Edit the moodle/user/view.php file and look for these lines (around line 349 in my 1.9.9 installation):&lt;br /&gt;
&amp;lt;code php&amp;gt;. format_string($mycourse-&amp;gt;fullname) . &amp;quot;&amp;lt;/a&amp;gt;, &amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
$courselisting .= format_string($mycourse-&amp;gt;fullname) . &amp;quot;, &amp;quot;;&amp;lt;/code&amp;gt;&lt;br /&gt;
* and change that to :&lt;br /&gt;
&amp;lt;code php&amp;gt;. format_string($mycourse-&amp;gt;fullname) . &amp;quot;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
$courselisting .= format_string($mycourse-&amp;gt;fullname) . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Then save&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Manage roles]] - including testing a new role&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=57812 Create a Parent of a student role] forum discussion &lt;br /&gt;
*[http://www.youtube.com/watch?v=-49YrtjMTTo Setting up a Parent Role video]&lt;br /&gt;
*[http://www.youtube.com/watch?v=P23GT2peLZI Parent Signing in on Moodle video]&lt;br /&gt;
&lt;br /&gt;
[[Category:Roles]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Guraso_rola]]&lt;br /&gt;
[[fr:Rôle Parent]]&lt;br /&gt;
[[ja:親ロール]]&lt;br /&gt;
[[de:Eltern-Rolle]]&lt;br /&gt;
[[nl:Ouder Rol]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Groupings&amp;diff=82134</id>
		<title>Groupings</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Groupings&amp;diff=82134"/>
		<updated>2011-03-21T10:00:24Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Assigning an activity to a grouping */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Groups}}&lt;br /&gt;
In Moodle 1.9 onwards, [[Groups|groups]] may be organised into groupings. In a nutshell, &#039;&#039;&#039;groupings&#039;&#039;&#039; are &#039;&#039;&#039;clusters of groups&#039;&#039;&#039;. Membership to the grouping depends upon being a member of a group associated with that grouping. The teacher can use a grouping as they would a group.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Enabling the use of groupings==&lt;br /&gt;
&lt;br /&gt;
In Moodle 1.9, groupings are an experimental feature, and so need enabling in order to use them. To do so, check the enablegroupings box in &#039;&#039;Administration &amp;gt; Miscellaneous &amp;gt; [[Experimental]]&#039;&#039;. A groupings tab will appear on the [[Groups]] page.&lt;br /&gt;
&lt;br /&gt;
In Moodle 2.0 onwards, groupings are always enabled. However, assigning an activity to group members in a particular grouping only is an experimental feature. If required, it may be enabled for the site by an administrator by checking the enablegroupmembersonly box in &#039;&#039;Administration &amp;gt; Development &amp;gt; Experimental&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Adding groups to a grouping==&lt;br /&gt;
[[Image:Groupings.png|thumb|Groupings]]&lt;br /&gt;
To add groups to a grouping: &lt;br /&gt;
#Follow the groups icon [[Image:Group.gif]] in the course administration block.&lt;br /&gt;
#Click the groupings tab on the groups page.&lt;br /&gt;
#If necessary, create a new grouping by clicking the &amp;quot;[[Create grouping]]&amp;quot; button on the groupings page.&lt;br /&gt;
#Click the &amp;quot;Show groups in grouping&amp;quot; people icon in the edit column opposite the grouping which groups are to be added to.&lt;br /&gt;
#On the add/remove groups page, select the group(s) you want to add to the grouping from the &amp;quot;Potential members&amp;quot; list.&lt;br /&gt;
#Click the arrow button that points towards the &amp;quot;Existing members&amp;quot; list.&lt;br /&gt;
#Click the &amp;quot;Back to groupings&amp;quot; button. The group(s) you added to the grouping will now be listed in the table on the groupings page.&lt;br /&gt;
&lt;br /&gt;
Existing groupings can be edited and/or deleted using the appropriate icons in the edit column of the table on the groupings page.&lt;br /&gt;
&lt;br /&gt;
==Setting the default grouping==&lt;br /&gt;
&lt;br /&gt;
Once some groupings have been created, a default grouping for course activities and resources may be set.&lt;br /&gt;
&lt;br /&gt;
#Follow the settings link in the course administration block.&lt;br /&gt;
#In the groups section in the [[Course settings|course settings]], select the default grouping.&lt;br /&gt;
&lt;br /&gt;
==Assigning an activity to a grouping==&lt;br /&gt;
[[Image:Restricting an activity to a grouping.png|thumb|Assigning an activity to a particular grouping only]]&lt;br /&gt;
To assign an activity to a particular grouping:&lt;br /&gt;
#On the edit activity page, click the &amp;quot;Show advanced&amp;quot; button in the common module settings section.&lt;br /&gt;
#Ensure that the group mode is set to separate or visible groups.&lt;br /&gt;
#Select the grouping from the grouping dropdown menu.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button at the bottom of the page.&lt;br /&gt;
&lt;br /&gt;
The name of the grouping will then appear in brackets after the activity name on the course page.&lt;br /&gt;
&lt;br /&gt;
A count of activities assigned to each grouping is kept on the groupings page.&lt;br /&gt;
&lt;br /&gt;
To assign an activity to group members in a particular grouping ONLY, in addition to the above, before clicking the the &amp;quot;Save changes&amp;quot; button, check the &amp;quot;Available for group members only&amp;quot; checkbox. You must also enable &#039;Enable group members only&#039; as this is an experimental setting in 2.0. This will result in only users assigned to the groups within the grouping being able to see the activity (or resource) on the course page.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Note&#039;&#039;: If a graded activity is assigned to a particular grouping only, it will still appear in the [[Grades|gradebook]] for all users unless gradebook categories are set up in a certain way. See MDL-13868 for further details.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Note&#039;&#039;: You cannot make an activity visible to only one group of students without first placing them into a Grouping. (See [[What is the difference between groups and groupings?]] for further details.)&lt;br /&gt;
&lt;br /&gt;
==Examples of groupings==&lt;br /&gt;
#Classroom teachers in different departments might tell some students to enroll in a refresher course. Each department has their own tutor.  Each student in the refresher course might be assigned to a group associated with their classroom teacher. The groups are put into department groupings.  For example, a University has Anthropology, Engineering and Computing departments with 3 or 4 teachers in each department that have their students take a refresher statistics class. While all students in the statistics class may receive some of the same material, groupings will allow a department focus, while still tracking students by their classroom teacher. If a student is not in a classroom group, they will not be in a department grouping.  And a student who is both in a Computing classroom group and an Engineering classroom group, will belong to more than one grouping.  &lt;br /&gt;
#In a class, you&#039;ve divided your students into 4 groups, each with their own author to research. Groups A and B, while they have different authors, are both assigned to write in a forum; groups C and D, though writing on different authors, are supposed to make a wiki. You might create a Forum Group&#039;&#039;ing&#039;&#039;, containing groups A and B, and a Wiki Group&#039;&#039;ing&#039;&#039;, containing groups C and D. Then, you can make the Wiki activity available to only the Wiki grouping, but you still have your two Wiki sub-groups, as well - C and D - for an added layer of distinction between the work going on about two different authors.&lt;br /&gt;
#Olympic metaphor: at the Olympics, there are different sports (gymnastics, swimming, track) and many countries. There are two ways to think of an Olympian athlete: by the sport they compete in, and by their nationality. To be part of the United States Olympic Team, you must first be a swimmer, a gymnast, or a runner. You cannot be in the US Team without first being an athlete in a specific sport. The sport is your group. Your country is your grouping. You must belong to a group before joining a grouping.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Groupings FAQ]]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=131905 Moodle Groups vs. Groupings] forum discussion including youtube video showing how to set up groupings&lt;br /&gt;
*[http://issuu.com/mariamoodle/docs/groupsandgroupings Moodle 1.9 Understanding Groups and Groupings] PDF 1.9 MB&lt;br /&gt;
*Curious about where &#039;groupings&#039; came from?  There is some discussion here: [[Development:Groupings OU]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Groups]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Groupements]]&lt;br /&gt;
[[ja:グルーピング]]&lt;br /&gt;
[[de:Gruppierungen]]&lt;br /&gt;
[[ca:Agrupaments]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=81855</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=81855"/>
		<updated>2011-03-11T04:37:57Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON) - this one must be run from the server context menu (master database?) and not from the Moodle database&#039;s context&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft on Windows ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] a new SQL Server 2005 Driver for PHP. This is a PHP extension that allows PHP scripts to read and write data on Microsoft SQL Server databases and it overcomes the problems with the native SQL Server extension that was previously bundled with PHP.&lt;br /&gt;
&lt;br /&gt;
This Microsoft driver is the standard database layer for running Moodle 2 under Microsoft SQL Server databases. See [[Using the Microsoft SQL Server Driver for PHP]] the installation and configuration details.&lt;br /&gt;
&lt;br /&gt;
This driver is only supported in Moodle 2.0 and up. You should use [https://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows FreeTDS] if you are installing an older version of Moodle.&lt;br /&gt;
&lt;br /&gt;
See MDL-16497 and MDL-15093 for more background information.&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
Note: the freetds.conf file you use should have &amp;quot;text size = 20971520&amp;quot; as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults. Also see [[FreeTDS]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MSSQL Support&lt;br /&gt;
! enabled&lt;br /&gt;
|-&lt;br /&gt;
| Library version &lt;br /&gt;
| FreeTDS &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=81854</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=81854"/>
		<updated>2011-03-11T04:34:45Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON) - this one must be run from the server context menu (master database?) and not from the Moodle database&#039;s context&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft on Windows ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] a new SQL Server 2005 Driver for PHP. This is a PHP extension that allows PHP scripts to read and write data on Microsoft SQL Server databases and it overcomes the problems with the native SQL Server extension that was previously bundled with PHP.&lt;br /&gt;
&lt;br /&gt;
This Microsoft driver is the standard database layer for running Moodle 2 under Microsoft SQL Server databases. See [[Using the Microsoft SQL Server Driver for PHP]] the installation and configuration details.&lt;br /&gt;
&lt;br /&gt;
This driver is only supported in Moodle 2.0 and up. You should use [https://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows FreeTDS] if you are installing an older version of Moodle.&lt;br /&gt;
&lt;br /&gt;
See MDL-16497 and MDL-15093 for more background information.&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
Note: the freetds.conf file you use should have &amp;quot;text size = 20971520&amp;quot; as mentioned in the FreeTDS on Windows section otherwise you might see sessions logging out or worse apache segmentation faults.&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MSSQL Support&lt;br /&gt;
! enabled&lt;br /&gt;
|-&lt;br /&gt;
| Library version &lt;br /&gt;
| FreeTDS &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=81853</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=81853"/>
		<updated>2011-03-11T04:28:11Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Using FreeTDS on Ubuntu by compiling an mssql.so extension */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON) - this one must be run from the server context menu (master database?) and not from the Moodle database&#039;s context&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft on Windows ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] a new SQL Server 2005 Driver for PHP. This is a PHP extension that allows PHP scripts to read and write data on Microsoft SQL Server databases and it overcomes the problems with the native SQL Server extension that was previously bundled with PHP.&lt;br /&gt;
&lt;br /&gt;
This Microsoft driver is the standard database layer for running Moodle 2 under Microsoft SQL Server databases. See [[Using the Microsoft SQL Server Driver for PHP]] the installation and configuration details.&lt;br /&gt;
&lt;br /&gt;
This driver is only supported in Moodle 2.0 and up. You should use [https://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows FreeTDS] if you are installing an older version of Moodle.&lt;br /&gt;
&lt;br /&gt;
See MDL-16497 and MDL-15093 for more background information.&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== FreeTDS on Linux (on Ubuntu by compiling an mssql.so extension) ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MSSQL Support&lt;br /&gt;
! enabled&lt;br /&gt;
|-&lt;br /&gt;
| Library version &lt;br /&gt;
| FreeTDS &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Using_the_Microsoft_SQL_Server_Driver_for_PHP&amp;diff=81695</id>
		<title>Using the Microsoft SQL Server Driver for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Using_the_Microsoft_SQL_Server_Driver_for_PHP&amp;diff=81695"/>
		<updated>2011-03-03T03:03:56Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Installation overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
== Using the SQL Server Driver for PHP from Microsoft ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This short manual is for running Moodle 2.0 (and upwards) using the Microsoft SQL Server (MSSQL) RDBMS. The steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
First of all, the minimum required version of MSSQL has been stabilized to MSSQL 2005 (v.9).&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
1. Install Microsoft SQL Server including SQL Server Management Studio. ([http://www.microsoft.com/sql/editions/express/default.mspx A free version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure to choose mixed authentication (Windows and local accounts) to keep things simpler later.  Define the &amp;quot;sa&amp;quot; account password when requested (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Configure Windows for MSSQL.&lt;br /&gt;
:By default, MSSQL listens to port 1433 for incoming TCP/IP connections and this port needs to be opened in the firewall. This is explicitly configured in the firewall installed (either Windows Firewall in the Control Panel or the configuration interface for other firewalls). If the port was changed when MSSQL was installed, then specify the correct port number to open in the firewall.&lt;br /&gt;
:Confirm the TCP/IP protocol is enabled in: &#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Create and configure a new database.&lt;br /&gt;
:Open &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.&lt;br /&gt;
*Execute the following command to enable Row Versioning:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 USE MASTER&lt;br /&gt;
 GO&lt;br /&gt;
 ALTER DATABASE &amp;amp;lt;your-database-name&amp;amp;gt; SET READ_COMMITTED_SNAPSHOT ON&lt;br /&gt;
 GO&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install PHP and a web server.&lt;br /&gt;
*PHP can be downloaded from [http://www.php.net/downloads.php www.php.net]&lt;br /&gt;
*If IIS is used as the web server, IIS 7.0 or later is recommended with [http://www.iis.net/download FastCGI and WinCache]. &lt;br /&gt;
&lt;br /&gt;
5. Install the SQL Server Driver for PHP.&lt;br /&gt;
:On the web server, install [http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9 SQL Server Driver for PHP] (minimum version required is v1.1) including all the pre-requisites listed on the download page. Note: it is critical to install the SQL Server Native Access Client version documented on the download page of the SQL Server Driver for PHP.&lt;br /&gt;
:Configure PHP to use the appropriate SQLSRV driver. In php.ini, set the following:&lt;br /&gt;
&lt;br /&gt;
For PHP 5.2.4 (or later)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 [PHP_SQLSRV]&lt;br /&gt;
 extension=php_sqlsrv_52_nts_vc9.dll&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For PHP 5.3.2 (or later)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 [PHP_SQLSRV]&lt;br /&gt;
 extension=php_sqlsrv_53_nts_vc9.dll&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Microsoft documentation for the SQL Server Driver for PHP is available at: http://msdn.microsoft.com/en-us/library/ee229548(v=SQL.10).aspx &lt;br /&gt;
&lt;br /&gt;
6. Install and configure Moodle.&lt;br /&gt;
:Continue with the [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
7. The Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;sqlsrv&#039;;         // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // Assuming that MSSQL is on the same server, otherwise &lt;br /&gt;
                                    // use the actual name or IP address of your database server&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // The name of the newly created Moodle database&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // Usually the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  true;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;           // The prefix can be changed per individual preferences, &lt;br /&gt;
                                    // but NEVER leave this blank!&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:If the config.php file doesn&#039;t exist, it will be generated as normal from the Moodle installer. Alternatively, use the config-dist.php file that comes with the Moodle package to create a custom config.php file.&lt;br /&gt;
&lt;br /&gt;
8. Restart or start your web server.&lt;br /&gt;
:If Moodle still cannot communicate with the database server, turn &#039;&#039;&#039;display_startup_errors&#039;&#039;&#039; to &amp;quot;On&amp;quot; in the /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
9. Test the database connection.&lt;br /&gt;
:Try this PHP script, just add a text file called test.php from the example below and change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to align with the config.php settings, and load from local host (http://localhost/test.php).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$link = sqlsrv_connect($this-&amp;gt;dbhost, array(&#039;UID&#039; =&amp;gt; &#039;db_user&#039;, &#039;PWD&#039; =&amp;gt; &#039;db_password&#039;));&lt;br /&gt;
if($link === FALSE) {&lt;br /&gt;
    echo &#039;Could not connect&#039;;&lt;br /&gt;
    die(&#039;Could not connect: &#039; . sqlsrv_errors(SQLSRV_ERR_ALL));&lt;br /&gt;
}&lt;br /&gt;
echo &#039;Successful connection&#039;;&lt;br /&gt;
sqlsrv_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. Complete the rest of the Moodle installation as usual.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Using_the_Microsoft_SQL_Server_Driver_for_PHP&amp;diff=81694</id>
		<title>Using the Microsoft SQL Server Driver for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Using_the_Microsoft_SQL_Server_Driver_for_PHP&amp;diff=81694"/>
		<updated>2011-03-03T03:03:32Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Installation overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
== Using the SQL Server Driver for PHP from Microsoft ==&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This short manual is for running Moodle 2.0 (and upwards) using the Microsoft SQL Server (MSSQL) RDBMS. The steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
First of all, the minimum required version of MSSQL has been stabilized to MSSQL 2005 (v.9).&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
1. Install Microsoft SQL Server including SQL Server Management Studio. ([http://www.microsoft.com/sql/editions/express/default.mspx A free version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure to choose mixed authentication (Windows and local accounts) to keep things simpler later.  Define the &amp;quot;sa&amp;quot; account password when requested (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Configure Windows for MSSQL.&lt;br /&gt;
:By default, MSSQL listens to port 1433 for incoming TCP/IP connections and this port needs to be opened in the firewall. This is explicitly configured in the firewall installed (either Windows Firewall in the Control Panel or the configuration interface for other firewalls). If the port was changed when MSSQL was installed, then specify the correct port number to open in the firewall.&lt;br /&gt;
:Confirm the TCP/IP protocol is enabled in: &#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Create and configure a new database.&lt;br /&gt;
:Open &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.&lt;br /&gt;
*Execute the following command to enable Row Versioning:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 USE MASTER&lt;br /&gt;
 GO&lt;br /&gt;
 ALTER DATABASE &amp;amp;lt;your-database-name&amp;amp;gt; SET READ_COMMITTED_SNAPSHOT ON&lt;br /&gt;
 GO&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install PHP and a web server.&lt;br /&gt;
*PHP can be downloaded from [http://www.php.net/downloads.php www.php.net]&lt;br /&gt;
*If IIS is used as the web server, IIS 7.0 or later is recommended with [http://www.iis.net/download FastCGI and WinCache]. &lt;br /&gt;
&lt;br /&gt;
5. Install the SQL Server Driver for PHP.&lt;br /&gt;
:On the web server, install [http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9 SQL Server Driver for PHP] (minimum version rquired is v1.1) including all the pre-requisites listed on the download page. Note: it is critical to install the SQL Server Native Access Client version documented on the download page of the SQL Server Driver for PHP.&lt;br /&gt;
:Configure PHP to use the appropriate SQLSRV driver. In php.ini, set the following:&lt;br /&gt;
&lt;br /&gt;
For PHP 5.2.4 (or later)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 [PHP_SQLSRV]&lt;br /&gt;
 extension=php_sqlsrv_52_nts_vc9.dll&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For PHP 5.3.2 (or later)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 [PHP_SQLSRV]&lt;br /&gt;
 extension=php_sqlsrv_53_nts_vc9.dll&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Microsoft documentation for the SQL Server Driver for PHP is available at: http://msdn.microsoft.com/en-us/library/ee229548(v=SQL.10).aspx &lt;br /&gt;
&lt;br /&gt;
6. Install and configure Moodle.&lt;br /&gt;
:Continue with the [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
7. The Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;sqlsrv&#039;;         // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // Assuming that MSSQL is on the same server, otherwise &lt;br /&gt;
                                    // use the actual name or IP address of your database server&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // The name of the newly created Moodle database&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // Usually the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  true;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;           // The prefix can be changed per individual preferences, &lt;br /&gt;
                                    // but NEVER leave this blank!&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:If the config.php file doesn&#039;t exist, it will be generated as normal from the Moodle installer. Alternatively, use the config-dist.php file that comes with the Moodle package to create a custom config.php file.&lt;br /&gt;
&lt;br /&gt;
8. Restart or start your web server.&lt;br /&gt;
:If Moodle still cannot communicate with the database server, turn &#039;&#039;&#039;display_startup_errors&#039;&#039;&#039; to &amp;quot;On&amp;quot; in the /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
9. Test the database connection.&lt;br /&gt;
:Try this PHP script, just add a text file called test.php from the example below and change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to align with the config.php settings, and load from local host (http://localhost/test.php).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$link = sqlsrv_connect($this-&amp;gt;dbhost, array(&#039;UID&#039; =&amp;gt; &#039;db_user&#039;, &#039;PWD&#039; =&amp;gt; &#039;db_password&#039;));&lt;br /&gt;
if($link === FALSE) {&lt;br /&gt;
    echo &#039;Could not connect&#039;;&lt;br /&gt;
    die(&#039;Could not connect: &#039; . sqlsrv_errors(SQLSRV_ERR_ALL));&lt;br /&gt;
}&lt;br /&gt;
echo &#039;Successful connection&#039;;&lt;br /&gt;
sqlsrv_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. Complete the rest of the Moodle installation as usual.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Installing_Oracle_for_PHP&amp;diff=81012</id>
		<title>Installing Oracle for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Installing_Oracle_for_PHP&amp;diff=81012"/>
		<updated>2011-02-02T08:58:03Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Install Moodle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* http://www.oracle.com/technology/pub/notes/technote_php_instant.html&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=65488#p308002 (with attached html document)&lt;br /&gt;
* http://es.php.net/oci8&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important Note:&#039;&#039;&#039; Don&#039;t forget to enable this variable in your php.ini (or .htaccess)  file:&lt;br /&gt;
&lt;br /&gt;
(else, all your data will be escaped following MySQL rules, that are incorrect for Oracle)&lt;br /&gt;
&lt;br /&gt;
    magic_quotes_sybase = On&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Broken versions of OCI8 driver ==&lt;br /&gt;
&lt;br /&gt;
PHP v5.2.4 (and perhaps v5.2.3 as well) have shipped with a bug in the OCI8 driver that leaks statement handles. The version of the OCI8 driver with the bug is v1.2.4. Possible workarounds:&lt;br /&gt;
&lt;br /&gt;
* Upgrade to PHP v5.2.5 or later&lt;br /&gt;
* Downgrade to PHP v5.2.1 (reported to work)&lt;br /&gt;
* Downgrade only the oci8 driver to the one included in PHP 5.2.1 (it worked for us -- iarenaza)&lt;br /&gt;
* If you are on linux and/or can compile PECL extensions, install an older OCI8 driver (v1.2.3 seems to work) from the PECL repository http://pecl.php.net/package/oci8&lt;br /&gt;
&lt;br /&gt;
More information at&lt;br /&gt;
* http://bugs.php.net/bug.php?id=42496 -- tracking the PHP OCI8 bug&lt;br /&gt;
* http://tracker.moodle.org/browse/MDL-11429 -- diagnostics on the Moodle side&lt;br /&gt;
&lt;br /&gt;
== Installing Moodle on Windows with Oracle Express Edition ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
This section explains how to install Moodle with Oracle Express Edition on Windows. I&#039;m using it for &#039;&#039;&#039;debugging&#039;&#039;&#039; purpose. It&#039;s definitively not a production environment. The goal is to setup easily and quickly a Moodle/Windows/Oracle environment.&lt;br /&gt;
&lt;br /&gt;
=== Install Oracle ===&lt;br /&gt;
Download Oracle Express Edition on [http://www.oracle.com/technology/products/database/xe/index.html Oracle web site].&amp;lt;br /&amp;gt;&lt;br /&gt;
You will also need the Instant client [http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html from here] (free account sign up needed). Copy everything from the unzipped folder into apache/bin. &amp;lt;br /&amp;gt;&lt;br /&gt;
Install both.&amp;lt;br /&amp;gt;&lt;br /&gt;
Access to the oracle console (http://127.0.0.1:8080/apex). Login: SYS Password: the_one_you_entered_during_the_installation&amp;lt;br /&amp;gt;&lt;br /&gt;
Create a new user and give it all rights (including DBA).&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: Oracle Express Edition 10g is limited at one database called &#039;XE&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Set up your oracle extension ===&lt;br /&gt;
This document does not explain how to setup apache/php for Oracle. You can have more information on [http://www.oracle.com/technology/tech/php/htdocs/php-oracle-tutorial.html Oracle Documentation]. On my own machine I used my WAMP installation ([http://www.en.wampserver.com/ Wampserver 2.0]) which allowed me to activate all oracle extensions in few clicks (php_oci8, php_oracle, php_pdo_oci, php_pdo_oci8).&lt;br /&gt;
&lt;br /&gt;
=== Install Moodle ===&lt;br /&gt;
On the database setup page:&amp;lt;br /&amp;gt;&lt;br /&gt;
Driver: Oracle oci8 (in the config file it should read &amp;quot;oci8po&amp;quot; for a 1.9.x install and &amp;quot;oci&amp;quot; for a 2.0.x install)&amp;lt;br /&amp;gt;&lt;br /&gt;
Host: empty the field&amp;lt;br /&amp;gt;&lt;br /&gt;
Database: //localhost:1521/XE&amp;lt;br /&amp;gt;&lt;br /&gt;
User: the user that you created&amp;lt;br /&amp;gt;&lt;br /&gt;
Password: the password you gave to the user&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure Apache ===&lt;br /&gt;
If you&#039;re running Moodle on Oracle with Apache on Linux, you might have issues with PHP being able to see the system environment variables.  To resolve this, you can edit /etc/sysconfig/apache2 and add the following lines to the bottom:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2# Set LANG Variables for UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
NLS_LANG=AMERICAN_AMERICA.AL32UTF8&amp;lt;br /&amp;gt;&lt;br /&gt;
LANG=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_ALL=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_COLLATE=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_CTYPE=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_MESSAGES=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_MONETARY=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_NUMERIC=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_TIME=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
export LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIM NLS_LANG LD_LIBRARY_PATH&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Also need to add those two lines to ~/.bashrc so that the PHP command-line client can see it too. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
* [http://lewiscarr.co.uk/node/4 Installing ORACLE drivers with PHP]&lt;br /&gt;
*[[Installing MSSQL for PHP]]&lt;br /&gt;
*[[PHP]]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=134729#p588963 Can i install Moodle with Oracle database]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=65488 Who uses Oracle]&lt;br /&gt;
*[https://docs.moodle.org/en/Step-by-step_Install_Guide_for_Solaris_10_with_Oracle_10 Step by step Install Guide for Solaris 10 with Oracle 10]&lt;br /&gt;
*[http://learningischange.com/2009/05/29/install-moodle-on-an-oracle-database-in-25-minutes-or-less/ Install Moodle on an Oracle Database (in 25 minutes or less)]. The related Using Moodle forum discussion is [http://moodle.org/mod/forum/discuss.php?d=124629 here].&lt;br /&gt;
*[http://www.mguhlin.org/2009/05/moodle-on-oracle-database.html Moodle on Oracle Database] discussion on Miguel Guhlin&#039;s blog &lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Installing_Oracle_for_PHP&amp;diff=81011</id>
		<title>Installing Oracle for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Installing_Oracle_for_PHP&amp;diff=81011"/>
		<updated>2011-02-02T08:57:37Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Install Moodle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* http://www.oracle.com/technology/pub/notes/technote_php_instant.html&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=65488#p308002 (with attached html document)&lt;br /&gt;
* http://es.php.net/oci8&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important Note:&#039;&#039;&#039; Don&#039;t forget to enable this variable in your php.ini (or .htaccess)  file:&lt;br /&gt;
&lt;br /&gt;
(else, all your data will be escaped following MySQL rules, that are incorrect for Oracle)&lt;br /&gt;
&lt;br /&gt;
    magic_quotes_sybase = On&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Broken versions of OCI8 driver ==&lt;br /&gt;
&lt;br /&gt;
PHP v5.2.4 (and perhaps v5.2.3 as well) have shipped with a bug in the OCI8 driver that leaks statement handles. The version of the OCI8 driver with the bug is v1.2.4. Possible workarounds:&lt;br /&gt;
&lt;br /&gt;
* Upgrade to PHP v5.2.5 or later&lt;br /&gt;
* Downgrade to PHP v5.2.1 (reported to work)&lt;br /&gt;
* Downgrade only the oci8 driver to the one included in PHP 5.2.1 (it worked for us -- iarenaza)&lt;br /&gt;
* If you are on linux and/or can compile PECL extensions, install an older OCI8 driver (v1.2.3 seems to work) from the PECL repository http://pecl.php.net/package/oci8&lt;br /&gt;
&lt;br /&gt;
More information at&lt;br /&gt;
* http://bugs.php.net/bug.php?id=42496 -- tracking the PHP OCI8 bug&lt;br /&gt;
* http://tracker.moodle.org/browse/MDL-11429 -- diagnostics on the Moodle side&lt;br /&gt;
&lt;br /&gt;
== Installing Moodle on Windows with Oracle Express Edition ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
This section explains how to install Moodle with Oracle Express Edition on Windows. I&#039;m using it for &#039;&#039;&#039;debugging&#039;&#039;&#039; purpose. It&#039;s definitively not a production environment. The goal is to setup easily and quickly a Moodle/Windows/Oracle environment.&lt;br /&gt;
&lt;br /&gt;
=== Install Oracle ===&lt;br /&gt;
Download Oracle Express Edition on [http://www.oracle.com/technology/products/database/xe/index.html Oracle web site].&amp;lt;br /&amp;gt;&lt;br /&gt;
You will also need the Instant client [http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html from here] (free account sign up needed). Copy everything from the unzipped folder into apache/bin. &amp;lt;br /&amp;gt;&lt;br /&gt;
Install both.&amp;lt;br /&amp;gt;&lt;br /&gt;
Access to the oracle console (http://127.0.0.1:8080/apex). Login: SYS Password: the_one_you_entered_during_the_installation&amp;lt;br /&amp;gt;&lt;br /&gt;
Create a new user and give it all rights (including DBA).&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: Oracle Express Edition 10g is limited at one database called &#039;XE&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Set up your oracle extension ===&lt;br /&gt;
This document does not explain how to setup apache/php for Oracle. You can have more information on [http://www.oracle.com/technology/tech/php/htdocs/php-oracle-tutorial.html Oracle Documentation]. On my own machine I used my WAMP installation ([http://www.en.wampserver.com/ Wampserver 2.0]) which allowed me to activate all oracle extensions in few clicks (php_oci8, php_oracle, php_pdo_oci, php_pdo_oci8).&lt;br /&gt;
&lt;br /&gt;
=== Install Moodle ===&lt;br /&gt;
On the database setup page:&amp;lt;br /&amp;gt;&lt;br /&gt;
Driver: Oracle oci8 (&amp;quot;oci8po&amp;quot; for a 1.9.x install and &amp;quot;oci&amp;quot; for a 2.0.x install)&amp;lt;br /&amp;gt;&lt;br /&gt;
Host: empty the field&amp;lt;br /&amp;gt;&lt;br /&gt;
Database: //localhost:1521/XE&amp;lt;br /&amp;gt;&lt;br /&gt;
User: the user that you created&amp;lt;br /&amp;gt;&lt;br /&gt;
Password: the password you gave to the user&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure Apache ===&lt;br /&gt;
If you&#039;re running Moodle on Oracle with Apache on Linux, you might have issues with PHP being able to see the system environment variables.  To resolve this, you can edit /etc/sysconfig/apache2 and add the following lines to the bottom:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2# Set LANG Variables for UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
NLS_LANG=AMERICAN_AMERICA.AL32UTF8&amp;lt;br /&amp;gt;&lt;br /&gt;
LANG=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_ALL=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_COLLATE=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_CTYPE=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_MESSAGES=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_MONETARY=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_NUMERIC=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_TIME=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
export LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIM NLS_LANG LD_LIBRARY_PATH&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Also need to add those two lines to ~/.bashrc so that the PHP command-line client can see it too. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
* [http://lewiscarr.co.uk/node/4 Installing ORACLE drivers with PHP]&lt;br /&gt;
*[[Installing MSSQL for PHP]]&lt;br /&gt;
*[[PHP]]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=134729#p588963 Can i install Moodle with Oracle database]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=65488 Who uses Oracle]&lt;br /&gt;
*[https://docs.moodle.org/en/Step-by-step_Install_Guide_for_Solaris_10_with_Oracle_10 Step by step Install Guide for Solaris 10 with Oracle 10]&lt;br /&gt;
*[http://learningischange.com/2009/05/29/install-moodle-on-an-oracle-database-in-25-minutes-or-less/ Install Moodle on an Oracle Database (in 25 minutes or less)]. The related Using Moodle forum discussion is [http://moodle.org/mod/forum/discuss.php?d=124629 here].&lt;br /&gt;
*[http://www.mguhlin.org/2009/05/moodle-on-oracle-database.html Moodle on Oracle Database] discussion on Miguel Guhlin&#039;s blog &lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Installing_Oracle_for_PHP&amp;diff=81010</id>
		<title>Installing Oracle for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Installing_Oracle_for_PHP&amp;diff=81010"/>
		<updated>2011-02-02T08:47:10Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Install Moodle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* http://www.oracle.com/technology/pub/notes/technote_php_instant.html&lt;br /&gt;
* http://moodle.org/mod/forum/discuss.php?d=65488#p308002 (with attached html document)&lt;br /&gt;
* http://es.php.net/oci8&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important Note:&#039;&#039;&#039; Don&#039;t forget to enable this variable in your php.ini (or .htaccess)  file:&lt;br /&gt;
&lt;br /&gt;
(else, all your data will be escaped following MySQL rules, that are incorrect for Oracle)&lt;br /&gt;
&lt;br /&gt;
    magic_quotes_sybase = On&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Broken versions of OCI8 driver ==&lt;br /&gt;
&lt;br /&gt;
PHP v5.2.4 (and perhaps v5.2.3 as well) have shipped with a bug in the OCI8 driver that leaks statement handles. The version of the OCI8 driver with the bug is v1.2.4. Possible workarounds:&lt;br /&gt;
&lt;br /&gt;
* Upgrade to PHP v5.2.5 or later&lt;br /&gt;
* Downgrade to PHP v5.2.1 (reported to work)&lt;br /&gt;
* Downgrade only the oci8 driver to the one included in PHP 5.2.1 (it worked for us -- iarenaza)&lt;br /&gt;
* If you are on linux and/or can compile PECL extensions, install an older OCI8 driver (v1.2.3 seems to work) from the PECL repository http://pecl.php.net/package/oci8&lt;br /&gt;
&lt;br /&gt;
More information at&lt;br /&gt;
* http://bugs.php.net/bug.php?id=42496 -- tracking the PHP OCI8 bug&lt;br /&gt;
* http://tracker.moodle.org/browse/MDL-11429 -- diagnostics on the Moodle side&lt;br /&gt;
&lt;br /&gt;
== Installing Moodle on Windows with Oracle Express Edition ==&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
This section explains how to install Moodle with Oracle Express Edition on Windows. I&#039;m using it for &#039;&#039;&#039;debugging&#039;&#039;&#039; purpose. It&#039;s definitively not a production environment. The goal is to setup easily and quickly a Moodle/Windows/Oracle environment.&lt;br /&gt;
&lt;br /&gt;
=== Install Oracle ===&lt;br /&gt;
Download Oracle Express Edition on [http://www.oracle.com/technology/products/database/xe/index.html Oracle web site].&amp;lt;br /&amp;gt;&lt;br /&gt;
You will also need the Instant client [http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html from here] (free account sign up needed). Copy everything from the unzipped folder into apache/bin. &amp;lt;br /&amp;gt;&lt;br /&gt;
Install both.&amp;lt;br /&amp;gt;&lt;br /&gt;
Access to the oracle console (http://127.0.0.1:8080/apex). Login: SYS Password: the_one_you_entered_during_the_installation&amp;lt;br /&amp;gt;&lt;br /&gt;
Create a new user and give it all rights (including DBA).&amp;lt;br /&amp;gt;&lt;br /&gt;
Note: Oracle Express Edition 10g is limited at one database called &#039;XE&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Set up your oracle extension ===&lt;br /&gt;
This document does not explain how to setup apache/php for Oracle. You can have more information on [http://www.oracle.com/technology/tech/php/htdocs/php-oracle-tutorial.html Oracle Documentation]. On my own machine I used my WAMP installation ([http://www.en.wampserver.com/ Wampserver 2.0]) which allowed me to activate all oracle extensions in few clicks (php_oci8, php_oracle, php_pdo_oci, php_pdo_oci8).&lt;br /&gt;
&lt;br /&gt;
=== Install Moodle ===&lt;br /&gt;
On the database setup page:&amp;lt;br /&amp;gt;&lt;br /&gt;
Driver: Oracle oci8 (oci8po for a 1.9.x install)&amp;lt;br /&amp;gt;&lt;br /&gt;
Host: empty the field&amp;lt;br /&amp;gt;&lt;br /&gt;
Database: //localhost:1521/XE&amp;lt;br /&amp;gt;&lt;br /&gt;
User: the user that you created&amp;lt;br /&amp;gt;&lt;br /&gt;
Password: the password you gave to the user&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure Apache ===&lt;br /&gt;
If you&#039;re running Moodle on Oracle with Apache on Linux, you might have issues with PHP being able to see the system environment variables.  To resolve this, you can edit /etc/sysconfig/apache2 and add the following lines to the bottom:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2# Set LANG Variables for UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
NLS_LANG=AMERICAN_AMERICA.AL32UTF8&amp;lt;br /&amp;gt;&lt;br /&gt;
LANG=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_ALL=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_COLLATE=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_CTYPE=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_MESSAGES=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_MONETARY=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_NUMERIC=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
LC_TIME=en_US.UTF-8&amp;lt;br /&amp;gt;&lt;br /&gt;
export LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIM NLS_LANG LD_LIBRARY_PATH&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Also need to add those two lines to ~/.bashrc so that the PHP command-line client can see it too. &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Related links ==&lt;br /&gt;
* [http://lewiscarr.co.uk/node/4 Installing ORACLE drivers with PHP]&lt;br /&gt;
*[[Installing MSSQL for PHP]]&lt;br /&gt;
*[[PHP]]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=134729#p588963 Can i install Moodle with Oracle database]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=65488 Who uses Oracle]&lt;br /&gt;
*[https://docs.moodle.org/en/Step-by-step_Install_Guide_for_Solaris_10_with_Oracle_10 Step by step Install Guide for Solaris 10 with Oracle 10]&lt;br /&gt;
*[http://learningischange.com/2009/05/29/install-moodle-on-an-oracle-database-in-25-minutes-or-less/ Install Moodle on an Oracle Database (in 25 minutes or less)]. The related Using Moodle forum discussion is [http://moodle.org/mod/forum/discuss.php?d=124629 here].&lt;br /&gt;
*[http://www.mguhlin.org/2009/05/moodle-on-oracle-database.html Moodle on Oracle Database] discussion on Miguel Guhlin&#039;s blog &lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Development:Scheduled_Tasks_Proposal&amp;diff=78576</id>
		<title>Development:Scheduled Tasks Proposal</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Development:Scheduled_Tasks_Proposal&amp;diff=78576"/>
		<updated>2010-12-02T05:33:27Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Tasks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This proposal is meant both to provide a replacement for the moodle cron job, and provide a means to schedule once off tasks to be run outside of the user&#039;s request lifecycle.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Subtask&#039;&#039;&#039; an individual piece of cron processing that should be run (equivalent to forum_cron now, or maybe even smaller)&lt;br /&gt;
* &#039;&#039;&#039;Moodle cron instance&#039;&#039;&#039; a cron.php process&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
The moodle cronjob currently delegates all scheduling to each subtask that is run - for example, the forum cron is responsible for checking when it last run, and making decisions about whether or not it should be run again.   This sort of decision process should be centralised, and individual cron subtasks should be called by the central controller.&lt;br /&gt;
&lt;br /&gt;
Additionally, there is not any central locking of subtasks.  At the moment, some subtasks that expect that they might take a long time to run implement their own locking (for example statistics), but it&#039;s not centralised.  Each moodle cron instance runs to completion, no matter how long it takes, and it processes tasks in the order that they&#039;re programmed, regardless of if there are any other moodle cron instances running, that might be processing sub tasks in parallel&lt;br /&gt;
&lt;br /&gt;
The existing events API seems like it should provide a way to schedule tasks to be run outside of a user&#039;s request cycle, but in reality this just adds to the existing cron problem.  We need to have a way in Moodle to schedule once off tasks to be run &amp;quot;at the next available time&amp;quot; which are picked up by cron.  This can be used to process the event queue, but also for some code to just register a new once off cron event &amp;quot;on the fly&amp;quot; and be picked up on the next run.&lt;br /&gt;
&lt;br /&gt;
Finally, we need to be able to run non-related tasks in parallel so that the entire moodle queue isn&#039;t held up by single long running jobs.&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
&lt;br /&gt;
* Centralised locking for &#039;&#039;&#039;all&#039;&#039;&#039; tasks&lt;br /&gt;
* A way consistent for &#039;&#039;&#039;all plugin types&#039;&#039;&#039; to register with Moodle (at installation/upgrade) when they want their jobs run&lt;br /&gt;
* More sophisticated scheduling rather than just intervals in seconds (eg every sunday at 11pm or similar) based on unix cron&lt;br /&gt;
* An administration screen in Moodle to allow site administrators to adjust the scheduling of individual tasks&lt;br /&gt;
* An easy way for core and module code to schedule a once off task to be run as soon as possible&lt;br /&gt;
&lt;br /&gt;
== Approach ==&lt;br /&gt;
&lt;br /&gt;
=== Plugin cron registration ===&lt;br /&gt;
&lt;br /&gt;
Each plugin will be able to provide a db/tasks.php (alongside access.php and events.php etc) that lists all the cronjobs that it wants to have run.  This will look something like the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$tasks = array(&lt;br /&gt;
    array(&lt;br /&gt;
        &#039;function&#039;    =&amp;gt; &#039;yourmodule_cron_somedescription&#039;,&lt;br /&gt;
        &#039;minute&#039;      =&amp;gt; &#039;*&#039;,&lt;br /&gt;
        &#039;hour&#039;        =&amp;gt; &#039;*&#039;,&lt;br /&gt;
        &#039;day&#039;         =&amp;gt; &#039;*&#039;,&lt;br /&gt;
        &#039;month&#039;       =&amp;gt; &#039;*&#039;,&lt;br /&gt;
        &#039;dayofweek&#039;   =&amp;gt; &#039;*&#039;,&lt;br /&gt;
        &#039;description&#039; =&amp;gt; &#039;langstringkey&#039;, // this must correspond to get_string(&#039;langstringkey&#039;, &#039;yourmodule&#039;);&lt;br /&gt;
    ),&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The fields are the same as normal unix cron, with the exception that you cannot use 3 letter words for the month and day of week fields like you can for unix cron.  The following is straight from the unix manpage about cron:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              field          allowed values&lt;br /&gt;
              -----          --------------&lt;br /&gt;
              minute         0-59&lt;br /&gt;
              hour           0-23&lt;br /&gt;
              day of month   1-31&lt;br /&gt;
              month          1-12 (or names, see below)&lt;br /&gt;
              day of week    0-7 (0 or 7 is Sun, or use names)&lt;br /&gt;
&lt;br /&gt;
       A field may be an asterisk (*), which always stands for ``first-last&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
       Ranges  of  numbers  are  allowed.  Ranges are two numbers separated with a hyphen.&lt;br /&gt;
       The specified range is inclusive.  For example, 8-11 for an ``hours&#039;&#039; entry specifies&lt;br /&gt;
       execution at hours 8, 9, 10 and 11.&lt;br /&gt;
&lt;br /&gt;
       Lists are allowed.  A list is a set of numbers (or ranges) separated by commas.&lt;br /&gt;
       Examples: ``1,2,5,9&#039;&#039;, ``0-4,8-12&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
       Step values can be used in conjunction with ranges.  Following a range with ``/&amp;lt;number&amp;gt;&#039;&#039;&lt;br /&gt;
       specifies  skips  of  the  number&#039;s  value  through  the  range.   For  example,&lt;br /&gt;
       ``0-23/2&#039;&#039; can be used in the hours field to specify command execution every other hour&lt;br /&gt;
       (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22&#039;&#039;).  Steps&lt;br /&gt;
       are also permitted after an asterisk, so if you want to say ``every two hours&#039;&#039;, just use ``*/2&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The unix crontab manpage goes on to say that one can use 3 letter words in the month and dayofweek fields (eg Sun or Feb).  I don&#039;t think this is necessary for our implementation.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;scheduled_tasks:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;Field&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Datatype&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Comment&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|integer&lt;br /&gt;
|sequence&lt;br /&gt;
|-&lt;br /&gt;
|plugintype&lt;br /&gt;
|varchar(50)&lt;br /&gt;
|plugintype - should match the path-style declarations in get_plugin_types (eg question/type, not qtype).  Will be null for core tasks.&lt;br /&gt;
|-&lt;br /&gt;
|pluginname&lt;br /&gt;
|varchar(50)&lt;br /&gt;
|name of the plugin. Will be null for core tasks.&lt;br /&gt;
|-&lt;br /&gt;
|callfunction&lt;br /&gt;
|varchar(200) (unique)&lt;br /&gt;
|the function to call. Must be unique, as it will be used for the locking.&lt;br /&gt;
|-&lt;br /&gt;
|lastruntime&lt;br /&gt;
|int(10)&lt;br /&gt;
|unix timestamp&lt;br /&gt;
|-&lt;br /&gt;
|nextruntime&lt;br /&gt;
|int(10)&lt;br /&gt;
|unix timestamp&lt;br /&gt;
|-&lt;br /&gt;
|blocking&lt;br /&gt;
|int(1)&lt;br /&gt;
|0 or 1 - whether this task, when running, blocks everything else from running.&lt;br /&gt;
|-&lt;br /&gt;
|minute&lt;br /&gt;
|varchar(25)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|hour&lt;br /&gt;
|varchar(25)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|day&lt;br /&gt;
|varchar(25)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|month&lt;br /&gt;
|varchar(25)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|dayofweek&lt;br /&gt;
|varchar(25)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|customised&lt;br /&gt;
|integer(1)&lt;br /&gt;
|0 or 1 - whether this time differs from what is in code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This table is for all the normal scheduled regular tasks.  The time fields are intially populated when a plugin is installed or upgraded, but can be overridden by an administrator, which sets the &amp;quot;customised&amp;quot; flag to 1.  If the administrator later decides to revert their customisation, the original code-values are repopulated into this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;scheduled_onceoff_tasks:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;Field&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Datatype&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Comment&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|id&lt;br /&gt;
|integer&lt;br /&gt;
|sequence&lt;br /&gt;
|-&lt;br /&gt;
|plugintype&lt;br /&gt;
|varchar(50)&lt;br /&gt;
|plugintype - should match the path-style declarations in get_plugin_types (eg question/type, not qtype).  Will be null for core tasks.&lt;br /&gt;
|-&lt;br /&gt;
|pluginname&lt;br /&gt;
|varchar(50)&lt;br /&gt;
|name of the plugin. Will be null for core tasks.&lt;br /&gt;
|-&lt;br /&gt;
|callfunction&lt;br /&gt;
|varchar(200) (unique)&lt;br /&gt;
|the function to call. Must be unique, as it will be used for the locking.&lt;br /&gt;
|-&lt;br /&gt;
|nextruntime&lt;br /&gt;
|int(10)&lt;br /&gt;
|unix timestamp&lt;br /&gt;
|-&lt;br /&gt;
|customdata&lt;br /&gt;
|text&lt;br /&gt;
|any data or serialised information&lt;br /&gt;
|-&lt;br /&gt;
|blocking&lt;br /&gt;
|int(1)&lt;br /&gt;
|0 or 1 - whether this task, when running, blocks everything else from running.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This table is for the once off tasks, which are run and then deleted.  There isn&#039;t a unique constraint on &#039;callfunction&#039; in this table, because the same once off task may be scheduled twice before the first one is processed.  In this case, the named lock will be obtained using a combination of callfunction and the id.&lt;br /&gt;
&lt;br /&gt;
The original database specification had extra custom fields in the main scheduled_tasks table, that the cronjobs could insert information into, called custom1 and custom2 and so on.  I&#039;ve removed these from this specification until such time as we have a solid use-case for them.  It is certain that we need it for the once off tasks, however, but in this case I think it&#039;s better to just have a text field that can either contain a single value, or a serialised blob of information.&lt;br /&gt;
&lt;br /&gt;
The original spec also had a priority field, but this has been removed after the conversation in Jizerka, which led to the proposal to just let some jobs block all others, rather than prioritising individual tasks.  &#039;&#039;&#039;This decision may be later reverted&#039;&#039;&#039; especially for once off tasks, where some may be really urgent.&lt;br /&gt;
&lt;br /&gt;
=== Locking ===&lt;br /&gt;
&lt;br /&gt;
Penny and Tim originally thought that the best approach was to try and do something that would cause an exception to be thrown - for example, try to insert into a row that had a unique constraint on it, and catch the exception.  However, this will cause far too much noise in the logs.  Matt Oquist came up with a different approach in MDL-21110.  We could potentially change this slightly to allow alternative implementations, by means of an abstract class and factory method (this was suggested by Sam Marshall), but probaby isn&#039;t needed for the initial implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Black magic ===&lt;br /&gt;
&lt;br /&gt;
Cron.php will need to be rewritten to look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
while ($nexttask = cron_get_next_task()) {&lt;br /&gt;
    cron_call_function($nexttask);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With some black magic to hand out the next task, which does:&lt;br /&gt;
&lt;br /&gt;
* Checks how long the existing process is allowed to run for&lt;br /&gt;
* Figures out if there&#039;s already a &amp;quot;blocking&amp;quot; task running&lt;br /&gt;
* Figures out the next task that&#039;s scheduled&lt;br /&gt;
* Tries to get a lock on it&lt;br /&gt;
* Returns that task&lt;br /&gt;
&lt;br /&gt;
== Unresolved issues/ideas ==&lt;br /&gt;
&lt;br /&gt;
* It might be nice at some point to find a way to allow different subtasks to run on different servers by designation.  This could be eventually added in to the administration screens as an extra setting (IP address)&lt;br /&gt;
* We obviously need some way to avoid different tasks trampling on eachother.  We ran through a number of ideas already, from differentiating between read/write operations, to having dependencies or conflicts between tasks, to having each task say which database tables it uses.   Finally we decided it would be best to just have some tasks that are able to simply block all others from being run.  Anything to do with authentication and enrolment must block other tasks from running, as otherwise there could be the problem of for example, forum posts being emailed out just before someone is unenrolled from a course.&lt;br /&gt;
* When the first cron in a long time is running, we should lock the entire cron and let it run to completeness, because the order is really important then.  This means that there also needs to be some global lastcronruntime flag somewhere (like in the config table)&lt;br /&gt;
&lt;br /&gt;
== Psuedo code proposal ==&lt;br /&gt;
Moved [[Development_talk:Scheduled_Tasks_Proposal|to the talk page]]&lt;br /&gt;
&lt;br /&gt;
== Audit of current cron ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Main section&lt;br /&gt;
! Subtask&lt;br /&gt;
! Frequency&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| session_gc&lt;br /&gt;
|&lt;br /&gt;
| every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/assignment&lt;br /&gt;
|plugins (none)&lt;br /&gt;
|every minute&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/assignment&lt;br /&gt;
|message submissions&lt;br /&gt;
|every minute&lt;br /&gt;
|checks last run time&lt;br /&gt;
|-&lt;br /&gt;
|mod/chat&lt;br /&gt;
|update chat times&lt;br /&gt;
|every five minutes&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/chat&lt;br /&gt;
|update_events&lt;br /&gt;
|every five minutes&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/chat&lt;br /&gt;
|delete old chat_users and add quits&lt;br /&gt;
|every five minutes&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/chat&lt;br /&gt;
|delete old messages&lt;br /&gt;
|every five minutes&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/data&lt;br /&gt;
|&lt;br /&gt;
|every minute&lt;br /&gt;
|no _cron function (includes file unnecessarily)&lt;br /&gt;
|-&lt;br /&gt;
|mod/forum&lt;br /&gt;
|mail posts&lt;br /&gt;
|every minute&lt;br /&gt;
|checks last run time&lt;br /&gt;
|-&lt;br /&gt;
|mod/forum&lt;br /&gt;
|digest processing&lt;br /&gt;
|every minute&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/forum&lt;br /&gt;
|delete old read tracking&lt;br /&gt;
|every minute&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|mod/scorm&lt;br /&gt;
|reparse all scorms&lt;br /&gt;
|every five minutes&lt;br /&gt;
|does hourly checking&lt;br /&gt;
|-&lt;br /&gt;
|mod/wiki&lt;br /&gt;
|delete expired locks&lt;br /&gt;
|every hour&lt;br /&gt;
|-&lt;br /&gt;
|blocks/rss_client&lt;br /&gt;
|update feeds&lt;br /&gt;
|every five minutes&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|quiz/report/statistics&lt;br /&gt;
|delete old statistics&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|admin/reports&lt;br /&gt;
|none&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|language_cache&lt;br /&gt;
&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|remove expired enrolments&lt;br /&gt;
|&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|main gradebook&lt;br /&gt;
|lock pending grades (*2)&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|main gradebook&lt;br /&gt;
|clean old grade history&lt;br /&gt;
|every run&lt;br /&gt;
|has a TODO to not process as often&lt;br /&gt;
|-&lt;br /&gt;
|event queue&lt;br /&gt;
|&lt;br /&gt;
|every run&lt;br /&gt;
|potentially large&lt;br /&gt;
|-&lt;br /&gt;
|portfolio cron&lt;br /&gt;
|clean expired exports&lt;br /&gt;
|every run&lt;br /&gt;
|potentially large&lt;br /&gt;
|-&lt;br /&gt;
|longtimenosee&lt;br /&gt;
&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|deleteunconfirmedusers&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|deleteincompleteusers&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|deleteoldlogs&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|deletefiltercache&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|notifyloginfailures&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|metacourse syncing&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|createpasswordemails&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|tag cron&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|clean contexts&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|gc_cache_flags&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|build_context_path&lt;br /&gt;
|&lt;br /&gt;
|20%&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|scheduled backups&lt;br /&gt;
|&lt;br /&gt;
|daily (admin defined)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|make rss feeds&lt;br /&gt;
|&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|auth/mnet&lt;br /&gt;
|keepalives&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|auth/mnet&lt;br /&gt;
|delete old sessions&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|auth/ldap&lt;br /&gt;
|sync users&lt;br /&gt;
|custom&lt;br /&gt;
|not scheduled (external cronjob)&lt;br /&gt;
|-&lt;br /&gt;
|auth/cas&lt;br /&gt;
|sync users&lt;br /&gt;
|custom&lt;br /&gt;
|not scheduled (external cronjob)&lt;br /&gt;
|-&lt;br /&gt;
|auth/db&lt;br /&gt;
|sync users&lt;br /&gt;
|custom&lt;br /&gt;
|not scheduled (external cronjob)&lt;br /&gt;
|-&lt;br /&gt;
|enrol/authorize&lt;br /&gt;
|clears old data&lt;br /&gt;
|daily (admin defined)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|enrol/authorize&lt;br /&gt;
|notifies administrators of old data&lt;br /&gt;
|daily (admin defined)&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|enrol/authorize&lt;br /&gt;
|process orders &amp;amp; email teachers&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|enrol/flatfile&lt;br /&gt;
|read file and sync users&lt;br /&gt;
|every run&lt;br /&gt;
|!?!&lt;br /&gt;
|-&lt;br /&gt;
|enrol/imsenterprise&lt;br /&gt;
|read file and sync users&lt;br /&gt;
|every run&lt;br /&gt;
|!?!?!&lt;br /&gt;
|-&lt;br /&gt;
|enrol/manual&lt;br /&gt;
|notify people of pending unenrolments&lt;br /&gt;
|daily&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|statistics&lt;br /&gt;
|&lt;br /&gt;
|daily (admin defined)&lt;br /&gt;
|huge&lt;br /&gt;
|-&lt;br /&gt;
|grade/import&lt;br /&gt;
|none&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|grade/export&lt;br /&gt;
|none&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|grade/reports&lt;br /&gt;
|none&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|fetch blog entries&lt;br /&gt;
|&lt;br /&gt;
|every run&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|file gc&lt;br /&gt;
|&lt;br /&gt;
|(optional) daily, else every run?&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|local cron&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
* Audit all existing cronjobs (done)&lt;br /&gt;
* Implement the locking code, either Matt&#039;s or something similar and write robust tests for it (this will be hard to test perhaps - can we test race conditions using simpletest?)&lt;br /&gt;
* Write the black magic that hands out the next task to be run for a given cron process&lt;br /&gt;
* Rewrite cron.php to use the black magic&lt;br /&gt;
* Migrate all the existing cronjobs to the new system&lt;br /&gt;
* Write screens to allow administrators to reschedule tasks&lt;br /&gt;
* Write code to transfer between unix-cron-syntax and user-friendly syntax (and vice versa)&lt;br /&gt;
* Write code to capture requests to schedule once off tasks&lt;br /&gt;
* Update portfolio code to use once off tasks rather than events API&lt;br /&gt;
* Evaluate integration of event API to once off tasks&lt;br /&gt;
* Test thoroughly&lt;br /&gt;
&lt;br /&gt;
The above tasks are now in MDL-25499 as sub-tasks to implement this proposal.&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Converting_your_MySQL_database_to_UTF8&amp;diff=77872</id>
		<title>Converting your MySQL database to UTF8</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Converting_your_MySQL_database_to_UTF8&amp;diff=77872"/>
		<updated>2010-11-18T04:04:34Z</updated>

		<summary type="html">&lt;p&gt;Aparup: /* Linux &amp;amp; Mac */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document looks at how to convert your MySQL database from the latin1 charset to UTF8. Moodle requires that your Database is now UTF8 and will not upgrade if your database is not, following the steps below will guide you in converting your database so that things once again work.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
&lt;br /&gt;
You may see the following error when upgrading your Moodle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;It is required that you store all your data in Unicode format (UTF-8). New installations must be performed into databases that have their default character set as Unicode. If you are upgrading, you should perform the UTF-8 migration process (see the Admin page).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Moodle requires UTF8 in order to provide better multilingual support and has done since Moodle 1.8. However the UTF8 check during install and upgrade has only been implemented recently and there are likely going to many users who find they are unable to upgrade because they did no set their database up correctly when they first installed Moodle, or for those who have been running Moodle from before 1.8 because they simply havn&#039;t already converted their database.&lt;br /&gt;
&lt;br /&gt;
For more information about UTF8 have a look at the doc on [https://docs.moodle.org/en/Unicode unicode].&lt;br /&gt;
&lt;br /&gt;
==Linux &amp;amp; Mac==&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mysqldump -uusername -ppassword -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B dbname &amp;gt; dump.sql&lt;br /&gt;
cp dump.sql dump-fixed.sql&lt;br /&gt;
vim dump-fixed.sql&lt;br /&gt;
:%s/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci/&lt;br /&gt;
:%s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/&lt;br /&gt;
:wq&lt;br /&gt;
mysql -uusername -ppassword &amp;lt; dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or alternatively using sed:&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
#  $1-dbusername $2-password $3-dbname&lt;br /&gt;
mysqldump -u$1 -p$2 -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B $3 &amp;gt; dump.sql&lt;br /&gt;
sed &#039;s/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci/&#039; &amp;lt;dump.sql | sed &#039;s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/&#039; &amp;gt;dump-fixed.sql&lt;br /&gt;
mysql -u$1 -p$2 &amp;lt; dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Explained===&lt;br /&gt;
The following steps will guide you in creating a database dumb, editing the database dump so that the correct charset and collation are used and then restoring the new database.&lt;br /&gt;
&lt;br /&gt;
To start please open a new terminal and move to a temp directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mysqldump -uusername -ppassword -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B dbname &amp;gt; dump.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first step is of course to dump out the database and of course we will use mysqldump for this. We do however need to set several arguments in order to clean up the charsets and provide a dump that is not going to cause you any problems if you are moving this database to a different database server or find yourself having to restore on a reverted system.&lt;br /&gt;
&lt;br /&gt;
; username : The username to access your database.&lt;br /&gt;
; password : The password for the above user.&lt;br /&gt;
; -c : Complete inserts for better compatibility.&lt;br /&gt;
; -e : Extended inserts for better performance.&lt;br /&gt;
; --default-character-set=utf8 : To set the default character set.&lt;br /&gt;
; --single-transaction : To reduce our workload if anything goes wrong.&lt;br /&gt;
; --skip-set-charset : Obviously not wanted or needed as we are changing it anyway.&lt;br /&gt;
; --add-drop-database : Required so we can restore over the top of our existing database.&lt;br /&gt;
; -B : We use this option so that our dump will contain drop table and create table syntax (which we will change the syntax for).&lt;br /&gt;
; dbname : The name of the database to convert.&lt;br /&gt;
&lt;br /&gt;
When you run this command a database dump will be generated into &#039;&#039;&#039;dump.sql&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cp dump.sql dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Next step is to copy dump.sql to dump-fixed.sql.&lt;br /&gt;
&lt;br /&gt;
We will make the desired changes within dump-fixed.sql and we will keep dump.sql as it is as a backup just in case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
vim dump-fixed.sql&lt;br /&gt;
:%s/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci/&lt;br /&gt;
:%s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/&lt;br /&gt;
:wq&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Now we need to edit the dump and correct the incorrect charsets that have been used. I have chosen to do this with VIM however you can use any search+replace editor or program. ( I choose VIM for this only because every linux user is/should be familiar with it).&lt;br /&gt;
&lt;br /&gt;
First we open the file using VIM, and then run the three commands.&lt;br /&gt;
&lt;br /&gt;
The first command replaces all instances of &#039;&#039;DEFAULT CHARACTER SET latin1&#039;&#039; with &#039;&#039;DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci&#039;&#039;. This is used to fix up the database&#039;s default charset and collation.&lt;br /&gt;
&lt;br /&gt;
The second command replaces all instances of &#039;&#039;DEFAULT CHARSET=latin1&#039;&#039; with &#039;&#039;DEFAULT CHARSET=utf8&#039;&#039;. This converts all tables from using latin1 to using UTF8.&lt;br /&gt;
&lt;br /&gt;
The third command simply saves it and exits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mysql -uusername -ppassword &amp;lt; dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Now that we&#039;ve made the required changes we simply need to restore the database over top of the existing database. We can do this by running the above command.&lt;br /&gt;
&lt;br /&gt;
==Windows==&lt;br /&gt;
Could someone who is familiar with Windows please convert the above into something that will work on Windows?&lt;br /&gt;
There are likely several additional arguments for mysqldump you will need to specify including setting the file for output using -r to avoid newline issues.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [https://docs.moodle.org/en/Unicode Moodle docs: Unicode]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=77603</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=77603"/>
		<updated>2010-11-09T07:31:49Z</updated>

		<summary type="html">&lt;p&gt;Aparup: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/19/en/index.php?title=Viewing_a_wiki&amp;diff=75965</id>
		<title>Viewing a wiki</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/19/en/index.php?title=Viewing_a_wiki&amp;diff=75965"/>
		<updated>2010-09-20T03:08:01Z</updated>

		<summary type="html">&lt;p&gt;Aparup: changed to say doble square brackets instead of single to add a page.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Wiki}}&lt;br /&gt;
This page is for documentation on how to use the wiki activity i.e. View, Edit, Links, History and is redirected from mod/wiki/view, a help page. &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
[[Image:Wiki_tabs.JPG]]&lt;br /&gt;
A wiki has 4 tabs, the most commonly used tabs are view and edit.&lt;br /&gt;
&lt;br /&gt;
==Adding a wiki page==&lt;br /&gt;
There are several ways to add a new wiki page.  In later versions of Moodle, the course participant&#039;s privileges can affect adding or editing wiki pages.  First you will create a link to a page that does not exist, then the wiki will create the blank page which someone can edit.&lt;br /&gt;
=== From a Wiki page===&lt;br /&gt;
This is the easiest way to add a page (or the first one that worked for me!).  Participants in a Wiki can create a new page by editing an existing Wiki page and adding a Wiki link that points to the page they want to create.  A Wiki link is simply any character string enclosed in square brackets.  The string is converted to a link by the following process:&lt;br /&gt;
&lt;br /&gt;
# Click the &#039;&#039;Edit&#039;&#039; tab on the front page of the Wiki &lt;br /&gt;
# In the edit box type the title of the new page that you want to create.  Enclose the title text in DOUBLE square brackets. Like this(but with double square brackets instead):  [[Image:Wiki non linked page example 1.JPG|center]]&lt;br /&gt;
# Click &#039;&#039;Save&#039;&#039;.&lt;br /&gt;
# The page you have just edited will now be displayed.  The words &amp;quot;My First Added Page&amp;quot; will be displayed with a question mark link immediately after it and may look like:[[Image:Wiki non linked page example 2.JPG|center]]&lt;br /&gt;
# Click on the &amp;quot;?&amp;quot; and you will be taken to an edit screen for a new page called:- &amp;quot;My First Added Page&amp;quot;&lt;br /&gt;
# Edit this new page with text as you will, and then click &#039;&#039;Save&#039;&#039;.  You just created a new wiki linkable page. &lt;br /&gt;
# Want to check the link by going back to the original Wiki page?  &lt;br /&gt;
##Click on the page link under &amp;quot;referring links&amp;quot; at the bottom of the new page in view mode.&lt;br /&gt;
##Another way is to click the &#039;&#039;- Choose Wiki Links -&#039;&#039; box, and then, from the drop down menu, select &#039;&#039;Site map&#039;&#039;.  Click on the original page displayed on the screen.  The words &amp;quot;My First Added Page&amp;quot; will have now become a link to your new page, a Wiki link.  &lt;br /&gt;
# Bingo!&lt;br /&gt;
&lt;br /&gt;
===Add by initial wiki creation===&lt;br /&gt;
When the teacher selects &#039;&#039;&#039;Wiki&#039;&#039;&#039; from the [[Adding resources and activities|Add an Activity&lt;br /&gt;
]] pull down menus in a course, they will be asked to create the first page.&lt;br /&gt;
&lt;br /&gt;
===Add by using search ===&lt;br /&gt;
In some versions of Moodle (not in 1.8 standard), any participant (with correct privileges) of an existing wiki can enter the name of the page they would like to create in the Search box on a wiki page.  For example they might enter the name &amp;quot;Roses&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
: If the page already exists &lt;br /&gt;
::they will be taken to the page &amp;quot;Roses&amp;quot;&lt;br /&gt;
: If the page does not exist, they will see:&lt;br /&gt;
:: &#039;&#039;&#039;There is no page titled &amp;quot;Roses&amp;quot;&#039;&#039;&#039; &lt;br /&gt;
::They can create this page by clicking on the &amp;quot;create this page&amp;quot; link &lt;br /&gt;
::and begin editing the new page called &amp;quot;Roses&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Editing a wiki page==&lt;br /&gt;
Editing the standard Moodle wiki is simple&lt;br /&gt;
* Click on the &#039;&#039;&#039;edit&#039;&#039;&#039; tag at the top of the wiki page&lt;br /&gt;
* Edit the text&lt;br /&gt;
* Then save the page, or preview the page before saving&lt;br /&gt;
&lt;br /&gt;
* Remember that MoodleDocs is a different(more robust and complicated) kind of wiki than the standard Moodle wiki. Many MoodleDoc or WikiMedia wiki tags (See [[Help:Editing]]) &#039;&#039;&#039;may not&#039;&#039;&#039; work in the standard Moodle wiki in versions 1.8 and earlier.&lt;br /&gt;
The standard help file gives the basics of editing in ErfurtWiki. See [http://moodle.org/help.php?module=wiki&amp;amp;file=howtowiki.html&amp;amp;forcelang=#createpages Moodle Help Docs on How to wiki]&lt;br /&gt;
&lt;br /&gt;
==Wiki search==&lt;br /&gt;
Wiki search ignores hyperlinks so it is wise to add a &amp;quot;Keywords:&amp;quot; line which contains the words of the the page title separated by commas, and any other entries that you wish to be found by the search.&lt;br /&gt;
&lt;br /&gt;
=NWiki=&lt;br /&gt;
&lt;br /&gt;
if you are using Ludo&#039;s new Nwiki module, there are some additional features.&lt;br /&gt;
&lt;br /&gt;
==Change to one of the following editors==&lt;br /&gt;
&lt;br /&gt;
Nwiki has several parsers, each one requiring a different sort of text. Its best to choose properly at the beginning, as altering half way through is not a good idea - they may well make a mess of text with a different formatting.&lt;br /&gt;
* HTMLeditor - the default editor that is used for all other moodle forms&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=115&amp;amp;filter=1 DFwiki] - the parsing engine from a previous third-party version of the wiki software. You or your students may be familiar with this and wish to continue using it&lt;br /&gt;
* Ewiki - the parsing engine from the previous default moodle wiki.&lt;br /&gt;
* nwiki - the most up to date engine, which is almost identical to the one used by wikipedia.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Also See==&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=1015 OUWiki] (Plugin)&lt;br /&gt;
* [http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=570 Tiddlywiki integration] (Plugin)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Teacher]]&lt;br /&gt;
[[Category:Wiki]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Afficher un wiki]]&lt;br /&gt;
[[de:Wiki ansehen]]&lt;br /&gt;
[[ja:Wikiを閲覧する]]&lt;/div&gt;</summary>
		<author><name>Aparup</name></author>
	</entry>
</feed>