"Alex D." <[EMAIL PROTECTED]> writes:

> here is a simple function that you can add to test.php in services/qooxdoo:
>    function method_query($params, $error)
>    {
>            $db = pg_connect("host=localhost dbname=test user=postgres");
>            $query = "SELECT * FROM test";
>            $result = pg_query($query);
>            return pg_fetch_row($result);
>
>    }
> You don't need to install a db in order to test it. PHP-script will not be
> able to connect to it and
> qx.io.remote.XmlHttpTransport will throw following error:
> *...Unable to connect to PostgreSQL server:...*
> But in RPC_1.html you'll become
> *Sync result: undefined*
> what means that callAsync() didn't becomme this error propagated.
>

Hi Alex,

Unfortunately, I can't find any way to catch errors that PHP considers
"Fatal".  I tried try/catch, set_error_handler(), and error_reporting, none of
which seem to be able to catch this.

This is, however, really a programming error.  The pg_* functions shouldn't be
being called if they don't exist.  Therefore, your query method could be
rewritten like this, which does solve the problem:

    <?php

    define("ApplicationError_FunctionUnavailable",  1);

    class class_fail
    {
       function method_query($params, $error)
       {
           if (! function_exists("pg_connect") ||
               ! function_exists("pg_query"))
           {
               $error->SetError(ApplicationError_FunctionUnavailable,
                                "pg_* functions are unavailable");
               return $error;
           }

           $db = pg_connect("host=localhost dbname=test user=postgres");
           $query = "SELECT * FROM test";
           $result = pg_query($query);
           return pg_fetch_row($result);
       }
    }

    ?>

I hope this helps.  If you know of a way in PHP to provide a more general
solution at the server level, please let me know!

(It's probably only necessary to do a single function_exists() call.  If
pg_connect exists, pg_query will too (and pg_fetch_row, which I didn't check
for.)

Cheers,

Derrell

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to