Sorry, forget this email, it is just a silly forward of my mail to php-db mailing list, where there's someone who said me that i must discuss about the C code with you...
Sorry. Samuel. Le mardi 06 octobre 2009 à 07:22 +0200, Samuel ROZE a écrit : > To use PostgreSQL's Notices with PDO, i'm modifying the source for > trying to store into "errmsg" (which I can get with PDO::errorInfo) the > notice. > > The "_pdo_pgsql_notice" function is called everytime that there's an > notice. The notice message is in the "message" var. This what i had > tried: > > --------------------------------------- > static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* > {{{ */ > { > pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; > pdo_pgsql_error_info *einfo = &H->einfo; > > einfo->errcode = 1; > > if (einfo->errmsg) { > pefree(einfo->errmsg, dbh->is_persistent); > einfo->errmsg = NULL; > } > einfo->errmsg = _pdo_pgsql_trim_message(message, dbh->is_persistent); > } > --------------------------------------- > > And in "pdo_pgsql_fetch_error_func", i've added an else condition to > view if errmsg is null are not... > > --------------------------------------- > if (einfo->errcode) { > add_next_index_long(info, einfo->errcode); > add_next_index_string(info, einfo->errmsg, 1); > } else { > zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, > "einfo->errcode is false : %s , %s", einfo->errcode, einfo->errmsg); > } > --------------------------------------- > > And, I've a function which send some notices (when I throw exception > from "_pdo_pgsql_notice" with the "message" var, I see the notice ! :-) > But, einfo->errcode is null ! > > -> Fatal error: Uncaught exception 'PDOException' with message > 'einfo->errcode is false : (null) , (null)' > in /etc/php-5.2.10/test/pgsql_notice.php:22 > Stack trace: > #0 /etc/php-5.2.10/test/pgsql_notice.php(22): PDO->errorInfo() > #1 {main} > thrown in /etc/php-5.2.10/test/pgsql_notice.php on line 22 > > Is anyone can help me ? > Thanks a lot ! > > Samuel. (French) > > Le lundi 05 octobre 2009 à 20:58 +0200, Samuel ROZE a écrit : > > Hi ! > > > > I'm reading the source of PDO PostgreSQL driver and i see that there's > > an empty function, _pdo_pgsql_notice, which is very interesting ! I > > think that it is used when PostgreSQL throw Notices. > > But, nothing is done... > > > > I want to know if somebody know why the content of the function is > > commented: > > > > static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* > > {{{ */ > > { > > /* pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; */ > > } > > > > (line 98 of /etc/pdo_pgsql/pgsql_driver.c - PHP 5.2 - r272374) > > > > How can I store the content of "message" into a field of the > > PDOStatement ? I view that there's only a "pdo_dbh_t" param, I may just > > store this message into a field of the PDO class ? > > > > Thanks in advance. > > Samuel. > > > > > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php