Re: Does PDO prevent class functions from calling other class functions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On 8/2/07, Ken Tozier <kentozier@xxxxxxxxxxx> wrote:
> I have a class
> that implements utility functions for database calls using PDO and am
> finding that I can't call one utility function from within another.

can you supply an error or warning that php is giving ?
it would help to determine the problem.

-nathan

On 8/2/07, Ken Tozier <kentozier@xxxxxxxxxxx> wrote:
>
> Hi
>
> I've been writing PHP classes for around two years now but all of a
> sudden, the things I used to do don't work any more. I have a class
> that implements utility functions for database calls using PDO and am
> finding that I can't call one utility function from within another.
> If each function is called by itself from a script, they work
> perfectly. This is really basic stuff so I'm very puzzled why it
> isn't working. The only difference between these new classes and my
> old classes is the use of PDO. Could PDO be causing all these headaches?
>
> Anyone see where I'm screwing up?
>
> Thanks in advance
>
> Ken
>
> Here's the '__construct' function of the included 'MySQLDatabase' class
>
> function __construct($inDomain, $inUser, $inPassword, $inDBName)
> {
>         try
>         {
>                 $this->db               = new
> PDO('mysql:host='.$inDomain.';dbname='.$inDBName,
> $inUser, $inPassword);
>
>                 // set error reporting
>                 $this->db->setAttribute(PDO::ATTR_ERRMODE,
> PDO::ERRMODE_EXCEPTION);
>         }
>         catch (PDOException $e)
>         {
>                 print "Error!: " . $e->getMessage() . "<br/>";
>                 die();
>         }
> }
>
> Here's the utility class so far
>
> <?php
>         // MySQLDatabase is a DB access class that handles a bunch of
> stuff
> like pulling values out of a query
>         // value coersion etc. I've tested this for the last day or so and
> it seems to be stable.
>         include_once('MySQLDatabase.php');
>
>         class PMXUtilities
>         {
>                 private $db;
>
>                 function __construct()
>                 {
>                         $domain                 = 'localhost';
>                         $user                   = 'root';
>                         $password               = '';
>                         $db_name                = 'pagemanager';
>
>                         $this->db               = new
> MySQLDatabase($domain, $user, $password, $db_name);
>                 }
>
>                 // if this is called on its own, it works
>                 function site_for_pub($inPubID)
>                 {
>                         $query                          = 'select site.id,
> site.site_name from site, publication
> where publication.id='.$inPubID.' and publication.site=site.id';
>                         $coersions                      = array('id'=>
> 'integer');
>                         $args                           = array('query'=>
> $query, 'coersions'=> $coersions);
>
>                         $queryResult            =
> $this->db->query_database($args);
>
>                         if (count($queryResult) > 0)
>                                 return $queryResult[0]['id'];
>                         else
>                                 return 'Error:
> PMXUtilities.site_for_pub_id failed while fetching
> site info for publication:'.$inPubID;
>                 }
>
>                 / if this is called on its own, it works
>                 function directory_type_id_for_name($inName)
>                 {
>                         $query                          = 'select id from
> directory_type where name="'.$inName.'"';
>                         $coersions                      = array('id'=>
> 'integer');
>                         $args                           = array('query'=>
> $query, 'coersions'=> $coersions);
>
>                         $queryResult            =
> $this->db->query_database($args);
>
>                         if (count($queryResult) > 0)
>                                 return $queryResult[0]['id'];
>                         else
>                                 return 'Error:
> PMXUtilities.site_for_pub_id failed while fetching
> directory type id for directory:'.$inName;
>                 }
>
>                 // this function never gets past the first "echo"
>                 function directory_path_for_pub_id($inPubID, $inDirType)
>                 {
>                         echo 'entered: directory_path_for_pub_id';
>
>                         // seems to die on next line as the 'echo site'
> line never prints
>                         $site                   =
> $this->site_for_pub_id($inPubID);
>                         echo 'site: '.$site.'<br>';
>                         /*
>                         $dirTypeID              =
> $this->directory_type_id_for_name($inDirType);
>                         echo 'dir_type: '.$dirTypeID.'<br>';
>
>                         $query                  = "select
> server.server_name, directory.path from
> directory, server, site where directory.type=".$dirTypeID." and
> directory.server=server.id and server.site=site.id and site.id=".$site;
>                         echo $query.'<br>';
>                         $queryResult    =
> $this->db->query_database($query);
>
>                         return
> $queryResult[0]->server_name.$queryResult[0]->path;
>                         */
>                 }
>
>         }
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux