Hi Derel,

First of all - thank you for your efforts.
And i think it's a misunderstanding - the problem is not that the 
function pg_connect() does not exist, but that the database doesn't 
exist. I have already secured pg_connect() with:
=======================
            $db = pg_connect("host=$dburl port=$dbport dbname=$dbname 
user=$dbuser password=$dbpwd");
            if( !$db){
                $error->SetError(JsonRpcError_ParameterMismatch, "Kann 
keine Verbindung mit der DB herstellen.");
                return $error;
            }
=======================
and i became following response from the backend:
=======================
 <br />

<b>Warning</b>:  pg_connect() [<a 
href='function.pg-connect'>function.pg-connect</a>]: 
Unable to connect to PostgreSQL server: FATAL:  database &quot;test&quot; does 
not exist
in <b>C:\.............php</b> on line <b>267</b><br />
{"error":{"origin":2,"code":5,"message":"Kann keine Verbindung mit der DB 
herstellen."},"id":11}

=======================
Thereupon qx.io.remote.XmlHttpTransport throws an error that i can see 
in the debug-console:
=======================
Could not execute json: [ <br />
<b>Warning</b>:  pg_connect().......(hier the backend response)
=======================
and qx.io.remote.RemoteRequest says:
Could not dispatch event of type "completed": TypeError - result has no 
properties

So the error is catched by the qx.io.remote.XmlHttpTransport(and by 
qx.io.remote.RemoteRequest) but it doesn't bubble up to my class.
But probably i didn't understand smth. In this case it will be great if 
you explain it.

Best Regards,
alex.d 
> 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