PEAR MDB2 Unknown Error

PEAR MDB2 Unknown Error

am 23.11.2007 20:04:47 von Rob Wilkerson

Hey all -

I'm bumping into an issue with my installation of the MDB2 package
that I'm hoping someone else has seen. I'm trying to execute a query,
but get an "unknown error" exception that I can't seem to track down
(exact message is "MDB2 Error: unknown error").

I have an ObjectDAO class (which I'm creating via a factory) that
extends an abstract DataAccessObject class. The database connection
is created in the parent class' constructor and a connection *is*
being established. I just can't seem to query against it. Here's the
code I'm trying to execute:

=======================================================

$dao = DAOFactory::createDAO ( 'Object' );
$result = $dao->conn->query ( 'SELECT COUNT(1) FROM object' );
if ( PEAR::isError ( $result ) ) {
echo '

SQL Error

';
throw new Exception ( $result->getMessage() );
}
new PHPDump ( $result->fetchRow() );

exit();

=======================================================

A dump of the $dao variable indicates that all properties and members
are public, as expected. Executing "./pear version" reveals:

PEAR Version: 1.6.2
PHP Version: 5.2.3
Zend Engine Version: 2.2.0

I've been fighting this all day and can't think of anything else to
try, nor can I find any additional information via Google. If
anyone's seen this, I'd really appreciate any insight.

Thanks.

Rob

Re: PEAR MDB2 Unknown Error

am 23.11.2007 23:41:50 von Rob Wilkerson

On Nov 23, 2:04 pm, Rob Wilkerson wrote:
> Hey all -
>
> I'm bumping into an issue with my installation of the MDB2 package
> that I'm hoping someone else has seen. I'm trying to execute a query,
> but get an "unknown error" exception that I can't seem to track down
> (exact message is "MDB2 Error: unknown error").
>
> I have an ObjectDAO class (which I'm creating via a factory) that
> extends an abstract DataAccessObject class. The database connection
> is created in the parent class' constructor and a connection *is*
> being established. I just can't seem to query against it. Here's the
> code I'm trying to execute:
>
> =======================================================
>
> $dao = DAOFactory::createDAO ( 'Object' );
> $result = $dao->conn->query ( 'SELECT COUNT(1) FROM object' );
> if ( PEAR::isError ( $result ) ) {
> echo '

SQL Error

';
> throw new Exception ( $result->getMessage() );}
>
> new PHPDump ( $result->fetchRow() );
>
> exit();
>
> =======================================================
>
> A dump of the $dao variable indicates that all properties and members
> are public, as expected. Executing "./pear version" reveals:
>
> PEAR Version: 1.6.2
> PHP Version: 5.2.3
> Zend Engine Version: 2.2.0
>
> I've been fighting this all day and can't think of anything else to
> try, nor can I find any additional information via Google. If
> anyone's seen this, I'd really appreciate any insight.

Looks like I've got some kind of problem connecting to MAMP's MySQL db
on OS X. I haven't tracked down what it might be, but attempting to
use the standard mysqli_connect() and mysql_connect() functions yield
a more verbose error that at least gives me somewhere else to look...

Re: PEAR MDB2 Unknown Error

am 24.11.2007 11:19:59 von petersprc

Hi,

You can get more info using $err->getUserInfo().

PAER error handling can also be triggered without checking isError:

PHP 5:

function Php5PearErrorHandler($err)
{
$ui = $err->getUserInfo();
$str = $err->getMessage();
if ($ui != '') {
$str .= ' (' . $ui . ')';
}
throw new PEAR_Exception($str, $err->getCode());
}

PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'Php5PearErrorHandler');

PHP 4:

function Php4PearErrorHandler($err)
{
$ui = $err->getUserInfo();
$str = $err->getMessage();
if ($ui != '') {
$str .= ' (' . $ui . ')';
}
trigger_error($str, E_USER_ERROR);
}

PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'Php4PearErrorHandler');

On Nov 23, 2:04 pm, Rob Wilkerson wrote:
> Hey all -
>
> I'm bumping into an issue with my installation of the MDB2 package
> that I'm hoping someone else has seen. I'm trying to execute a query,
> but get an "unknown error" exception that I can't seem to track down
> (exact message is "MDB2 Error: unknown error").
>
> I have an ObjectDAO class (which I'm creating via a factory) that
> extends an abstract DataAccessObject class. The database connection
> is created in the parent class' constructor and a connection *is*
> being established. I just can't seem to query against it. Here's the
> code I'm trying to execute:
>
> =======================================================
>
> $dao = DAOFactory::createDAO ( 'Object' );
> $result = $dao->conn->query ( 'SELECT COUNT(1) FROM object' );
> if ( PEAR::isError ( $result ) ) {
> echo '

SQL Error

';
> throw new Exception ( $result->getMessage() );}
>
> new PHPDump ( $result->fetchRow() );
>
> exit();
>
> =======================================================
>
> A dump of the $dao variable indicates that all properties and members
> are public, as expected. Executing "./pear version" reveals:
>
> PEAR Version: 1.6.2
> PHP Version: 5.2.3
> Zend Engine Version: 2.2.0
>
> I've been fighting this all day and can't think of anything else to
> try, nor can I find any additional information via Google. If
> anyone's seen this, I'd really appreciate any insight.
>
> Thanks.
>
> Rob

Re: PEAR MDB2 Unknown Error

am 24.11.2007 15:17:24 von Rob Wilkerson

On Nov 24, 5:19 am, petersprc wrote:
> Hi,
>
> You can get more info using $err->getUserInfo().
>
> PAER error handling can also be triggered without checking isError:
>
> PHP 5:
>
> function Php5PearErrorHandler($err)
> {
> $ui = $err->getUserInfo();
> $str = $err->getMessage();
> if ($ui != '') {
> $str .= ' (' . $ui . ')';
> }
> throw new PEAR_Exception($str, $err->getCode());
> }
>
> PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'Php5PearErrorHandler');

For what it's worth, it looks like my problem was in the way my MySQL
user was created. I didn't realize that "%" meant any host OTHER THAN
localhost. I thought it just meant "any host" (including localhost).
Thats for the error handling information, though. That may come in
handy.