[PHP] Re: [PHP3] WHAT is PEAR?

2004-02-04 Thread David Clymer
On Wed, 07 Jun 2000 02:51:45 -0500, Richard Lynch wrote:

 In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Cheng, Cheng-Wei) wrote:
 
 I see this term a lot
 but cannot find the explaination in the documentation.
 
 I think that's the nifty feature whereby you can easily load sub-modules
 into PHP4 (like the MySQL support) without re-compiling all of PHP...
 
 But I'm short on sleep, so maybe I'm just confusing things.

Have you ever used Perl? Its very similar to CPAN. In other words,
PEAR (PHP Extension  Application Repository), is a big collection
of PHP classes which you can search and download using the pear 
utility. Once they are downloaded (usually into a directory in
PHP's include path) you can include them and use them just like 
any class you write.

-davidc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PEAR DB::isError acting strange

2004-02-03 Thread David Clymer
I'm having some problems with the DB::isError function identifying a
non-object as an error object (or so it seems). I'm using postgreSQL
7.3.x. The relevant code is below:

/***[ my code start ]***/

   $sql_queries = array();

$sql_queries[0] =  'BEGIN';
$sql_queries[1] = INSERT INTO domain (name,table_name)
VALUES('$domainname','$tablename');
$sql_queries[2] = 'CREATE TABLE ' . $tablename . '_account ()
INHERITS (domain_account_template)';
$sql_queries[3] = 'CREATE TABLE ' . $tablename . '_alias () INHERITS
(domain_alias_template)';
$sql_queries[4] = 'CREATE TABLE ' . $tablename . '_option ()
INHERITS (domain_account_template)';
$sql_queries[5] = 'END';
 
// go though and execute all the queries (it fails on the 
// first one
foreach($sql_queries as $query)
{
  // show me which query is executing
  echo $query . br/;
  $result = $db-query($query);

  // this tells me that  $result is an integer == 1 and 
  // so is DB_OK, which I believe the code above is returning
  echo  getType($result) . :  . $result . :  . DB_OK . br/;

  //this test tells me that it is NOT an object  
  if(is_object($result)) { echo its an object.; }
  else {echo its NOT an object; }
   

  //this always ends up as true, because it executes the code
  //in this block
  if(DB::isError($result));
  {
//at this point, I get a fatal error saying that I'm 
//attempting to call a member function on a non-object
$error = $result-getMessage() . $result-getDebugInfo();
$db-query('ABORT');
die($error);
  }
}

/[ my code end ]***/

now, when I looked at the DB::isError code, it looked like so:

/**
 * Tell whether a result code from a DB method is an error
 *
 * @param int $value result code
 *
 * @return bool whether $value is an error
 *
 * @access public
 */
function isError($value)
{
return (is_object($value) 
(get_class($value) == 'db_error' ||
 is_subclass_of($value, 'db_error')));
}

So, it seems, that although I've already found (in my code) that the
variable in question is NOT an object, isError STILL finds that it is
not only an object, but is an object of class db_error!

I'm really confused. Clearly I'm missing something here. Does anyone
have any pointers for me?

-davidc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php