Trying to test ODBTP+MSSQL+MOODLE, need help

Trying to test ODBTP+MSSQL+MOODLE, need help

Jay Lee -
回帖数:6
I'm attempting to use ODBTP in order to store my Moodle data in a SQL 2005 Server. I've had some success previously using FreeTDS but since ODBTP seems to be the recommend method, I'd like to start using that. However I can't seem to get Moodle to work with ODBTP loaded. I've tried this both on a RHEL4 PHP box on which I custom compiled a php_odbtp.so module (with MSSQL support enabled by editing the Makefile) and I've tried on a Windows box using the php_odbtp_mssql.dll that ships with the ODBTP package. Neither one seems to work. On both, when I create a simple phpinfo() test page, I can see that ODBTP is registered with PHP and appears to be working, however there is nothing for MSSQL. As I understood it, ODBTP with MSSQL enabled should give PHP the mssql_ functions similar to what the original php_mssql did and I believe that those functions is what Moodle is looking for. Is that right?

I'm fairly certain that I've correctly enabled MSSQL in ODBTP because when I modify the Makefile, the resultant binary is about 5k larger. Should I see any difference in phpinfo()? Should I be choosing something other than mssql_n during the install.php database page? How does Moodle detect ODBTP or another way of using the mssql functions?

Thanks for any tips you can provide.

Jay Lee
回复Jay Lee

Re: Trying to test ODBTP+MSSQL+MOODLE, need help

Jay Lee -
Interesting, I created a little test script to see how things look (this is on the RHEL4 linux box)

test2.php:

<?php
if (function_exists('odbtp_connect'))
echo "odbtp_connect function exists<br>";
if (function_exists('mssql_connect'))
echo "mssql_connect function exists<br>";
?>

This test2.php returns that both functions exist. Still not sure why Moodle doesn't seem to think MSSQL support exists, will continue to test things out while I wait to hear back from others...

Jay
回复Jay Lee

Re: Trying to test ODBTP+MSSQL+MOODLE, need help

Jay Lee -
Of further interest, install.php shows this little segment:

if ($INSTALL['dbtype'] == 'mssql_n') { /// Check MSSQL extension is present
if (!extension_loaded('mssql')) {
$errormsg = get_string('mssqlextensionisnotpresentinphp', 'install');
$nextstage = DATABASE;
}
}

this doesn't seem to work for odbtp module installs. I am using odbtp 1.1.4, is it possible this newer version doesn't register itself as mssql where older ones did? Changing extension_loaded('mssql') to extension_loaded('odbtp') allowed me to get further but I think I still have issues with my odbtp.conf and settings, will continue to tweak and wait to hear back from anyone who knows why Moodle can't seem to detect odbtp, thanks guys.

Jay
回复Jay Lee

Re: Trying to test ODBTP+MSSQL+MOODLE, need help

Eloy Lafuente (stronk7) -
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像 Testers的头像
Hi Jay,

in order to allow the ODBTP extension to replace the standard MSSQL extension, you must disable the standard one. Else, the ODBTP won't be able to mimic the original one due to function name conflicts. From the ODBTP site: http://odbtp.sourceforge.net/phpext.html#mssql

Also, note that the ODBTP extension itself has to be built with the "replacement feature" enabled. This can be achieved by:

- for static builds, recompile PHP with the --with-odbtp-mssql option
- for shared builds, compile the ODBTP extension with the -DODBTP_MSSQL uncommented in the Makefile.

I've compiled it successfully both under Linux and MacOS X and the extension for Win32 that comes with the official download of ODBTP works perfectly too in my tiny laptop. In all places using 1.1.4.

Ciao 微笑

PD: About nothing related to "MSSQL" being showed in the PHPInfo page I can confirm you that, yep, nothing is showed, just the ODBTP extension. But it does the replacement job, indeed.
回复Eloy Lafuente (stronk7)

Re: Trying to test ODBTP+MSSQL+MOODLE, need help

Jay Lee -
>in order to allow the ODBTP extension to replace the standard MSSQL >extension, you must disable the standard one. Else, the ODBTP won't be able to >mimic the original one due to function name conflicts. From the ODBTP site: >http://odbtp.sourceforge.net/phpext.html#mssql

I have tested the PHP 5.1.6 windows build with no modules but php_odbtsp, php_gd2 and php_zlib loaded. I did not have php_mssql loaded. I have also tested under RHEL4u4 which does not ship the php-mssql module at all. I am quite confident that ODBTP is the only thing providing mssql functions in both php installs.

>Also, note that the ODBTP extension itself has to be built with the "replacement >feature" enabled. This can be achieved by:
>
>- for static builds, recompile PHP with the --with-odbtp-mssql option
>- for shared builds, compile the ODBTP extension with the -DODBTP_MSSQL >uncommented in the Makefile.

Yes, I've done that. As my test in on of my replies shows, mssql functions are present but php does not believe the mssql extension is loaded.

>I've compiled it successfully both under Linux and MacOS X and the extension for >Win32 that comes with the official download of ODBTP works perfectly too in >my tiny laptop. In all places using 1.1.4.

Did you do a complete install or did you switch over from FreeTDS/php_mssql? I am becoming convinced that with ODBTSP installed and no other mssql module, the expression:

if (!extension_loaded('mssql'))

will always evaluate false. At least I've managed to somehow install ODBTP and that evaluates false while:

if (!function_exists('mssql_connect'))

evaluates to true. Maybe we should be looking for the function instead of the extension?

>PD: About nothing related to "MSSQL" being showed in the PHPInfo page I can >confirm you that, yep, nothing is showed, just the ODBTP extension. But it does >the replacement job, indeed.

changing the check like above allowed me to complete the install on my Win32 box, I'm still running into some issues on my RHEL4u4 x86_64 box though, for some reason nothing is being returned for the SQL version (should return 9.0.xxxx something). I need to play with it more.
回复Jay Lee

Re: Trying to test ODBTP+MSSQL+MOODLE, need help

Eloy Lafuente (stronk7) -
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像 Testers的头像
Ah Jay,

so your problems were at install time, not at compile or general use (sorry, I misunderstood the problem).

And yep, there is a problem under ODBTP not "publishing" the "mssql" extension as loaded (like freeTDS does). Believe me if I say that I've been using both drivers randomly in the last months and, casualty, it seem that all the (dozens) installation-tests I've done, always I've used FreeTDS, Murphy in action!

We'll change the "mssql" test as suggested by you ASAP. Tons of thanks! 装酷

Ciao 微笑
回复Eloy Lafuente (stronk7)

Re: Trying to test ODBTP+MSSQL+MOODLE, need help

Jay Lee -
Thanks Eloy and thanks for all your work on the mssql code. We are really excited about being able to store moodle in the same RDMS as our primary student records database so that we can build bridges between. Thanks again,

Jay