TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kohana 2.3.4 MSSQL not working
  • Hello. we're migrating our application from mysql to mssql , and encountered a problem fetching rows from result:

            $db = Database::instance(); //connection successfull
            $q  = $db->query("select CURRENT_TIMESTAMP as t");  //query successful. total_rows = 1
            $r  = $q->current();  //r is empty object !
            $t  = $r->t;   //Exception: Undefined property: stdClass::$t
    

    please help, Thanks in advance

  • @MichaelOstrovsky, you probably aren't going to get much help on that issue. Kohana 2.3.4 is very old and few people used the mssql database driver. Have you try debugging it and inspecting the database result object to see what is in it?

  • Support of MSSQL is formally stated for that version. It's not trivial to rewrite Kohana drivers.. just being sorry for choosing Kohana's ORM in first place.

    Thanks

  • I'm not sure we "formally stated support" for mssql in 2.x. We didn't have the proper resources to maintain it.

  • I mean that mssql was one of the provided drivers in that release, which implicitly mean that it works.. at least at the very basic level. http://docs.kohanaphp.com/libraries/database/configuration I obviously can't demand anything.. but it would be very nice if someone from the dev could take a short glance. it might take 5 minutes for him to figure out the problem, whereas it's a whole project for us.

    thanks

  • It takes more than 5 minutes to set up a development environment with an old release of the software and an MSSQL database. The latter might not even be possible.

    Could you post the output of var_dump($q);.

    Things to check:

    • Is caching enabled? (Has a bad result been cached)
  • Just posting these links for reference (incase I lose them, or someone else wants to look at them). I'm not entirely sure they're to the right version of kohana though, so don't count on them.

  • @MichaelOstrovsky You can make a few minor modifications to get the Leap ORM to work with Kohana 2.3.4, which has a plugin that works with MS SQL (as well as other databases). Essentially, you would need to create an autoload function to load the classes and modified the Kohana::$config->load() and the Arr::get() methods since the Leap ORM is designed for Kohana 3.2. If you want, you can fork Leap ORM on github and modify it for Kohana 2.3.4 and then I can move your changes into its own branch for others to use. It should be a pretty simple to adapt Leap to Kohana 2.3.4.

    The nice thing about LEAP with MS SQL is that you can use its query builder, which will escape values accordingly. It will also allow you to select between the mssql_* functions or the PDO functions quickly and easily.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion