Re: [PHP] Reading registry values

2007-08-01 Thread Travis D
On 7/31/07, Crash Dummy <[EMAIL PROTECTED]> wrote:
>
> > Hope this isn't overkill but it is a module (read "COM", or "VBA
> module")
> > to manipulate the registry:
>
> "Overkill" is a massive understatement. :-)



No doubt.

To answer everyone's curiosity as to why I want to access the registry, I am
> working on my home computer with a dynamic IP, and I need to know what it
> is so
> I can modify my httpd.conf (or hosts) file, if necessary.


You might use http://www.php.net/reserved.variables "SERVER_ADDR" to get the
address of the host you are running under if you wanted to access it from
PHP only.

Travis Doherty


Re: [PHP] Unexpected values in an associative array

2007-08-01 Thread Travis D
On 7/31/07, Ken Tozier <[EMAIL PROTECTED]> wrote:
>
> ...
>
   // set fetch prefs
> $this->db->setAttribute(PDO:: FETCH_ASSOC,
> true);   // also tried 1
>  ...
>
Is that the way to do it?


Hmm.. Maybe I sent you in the wrong direction - I can't find any docs on
using setAttribute to set the fetch mode.  Anyway, setAttribute always works
like this:
setAttribute(attribute_to_set,value_to_set_to);

I was expecting something like:
setAttribute(PDO::FETCH_MODE, PDO::FETCH_ASSOC);

I don't think that works though, can't find anything in docs relating to
attribute called FETCH_MODE.  Anyway I dug in some code and this is what you
can do:

foreach ($pdo->query($query, PDO::FETCH_ASSOC)) {}

Query can take a second parameter.

Another option:
PDOStatement->setFetchMode(PDO::FETCH_ASSOC).. so your original code goes
from:

foreach ($pdo->query($query) as $row) {}

To:

$statement = $pdo->query($query);
$statement->setFetchMode(PDO::FETCH_ASSOC);
foreach( $statement as $row) {}

There must be a way to set it with setAttribute for the connection though,
instead of just on a per-statement basis...

Travis Doherty