php-general Digest 15 Mar 2008 23:16:54 -0000 Issue 5350

Topics (messages 271647 through 271649):

Re: Sendmail question
        271647 by: Manuel Lemos

Objects as array key names??
        271648 by: Jim Lucas
        271649 by: Ray Hauge

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hello,

on 03/14/2008 12:35 PM nihilism machine said the following:
> So the email should be a link to:
> http://www.mysite.com/permalink.php?ID=120
> but instead links to: http://www.mysite.com/permalink.php?ID%120

The problem is that you have specified quoted-printable encoding and
have not properly encoded all characters in the HTML.

I recommend that you a class that knows how to properly message bodies
with quoted-printable. I use the MIME message class. Take a look at the
test_simple_html_mail.php example script.

http://www.phpclasses.org/mimemessage


-- 

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message --- This question should probably be directed at the PHP Internals list, but I thought I would start by asking here first if anybody would even use this feature.

It has been brought to my attention that with Perl and Ruby, you can use Objects as the value of the key within an array. The examples that were shown to me make me think that this would be an awesome ability to have within PHP.

Here is an example of how I would use such a feature.

I have a table of "customers".
I have a table customers "contact_locations".
        This table has a reference ID back to the "customers" table.

Now, in my array of information that I build I have this.

$res = query('Select c_id, c_first_name, c_last_name FROM customers');

$customers = array();
while ( $row = fetch_assoc($res) ) {
        $customers[$row]['contact_locations'] = array();
        $SQL = "SELECT *
                FROM contact_locations
                WHERE c_id={$row['c_id']}";
        $loc_res = query($SQL);
        while ( $loc_row = fetch_assoc($loc_res) ) {
                $customers[$row]['contact_locations'][] = $loc_row;
        }
}


Now, contained within one array "$customers" I have all the information that would be needed for displaying any type of information related to a customer or a customers location.

By doing having this feature, I could build the ability to do xPath searches within the base array. That would be nice.

Anyways, what do you all think?  Worth it or not?

Jim Lucas

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
This question should probably be directed at the PHP Internals list, but I thought I would start by asking here first if anybody would even use this feature.

It has been brought to my attention that with Perl and Ruby, you can use Objects as the value of the key within an array. The examples that were shown to me make me think that this would be an awesome ability to have within PHP.

Here is an example of how I would use such a feature.

I have a table of "customers".
I have a table customers "contact_locations".
    This table has a reference ID back to the "customers" table.

Now, in my array of information that I build I have this.

$res = query('Select c_id, c_first_name, c_last_name FROM customers');

$customers = array();
while ( $row = fetch_assoc($res) ) {
    $customers[$row]['contact_locations'] = array();
    $SQL = "SELECT *
        FROM contact_locations
        WHERE c_id={$row['c_id']}";
    $loc_res = query($SQL);
    while ( $loc_row = fetch_assoc($loc_res) ) {
        $customers[$row]['contact_locations'][] = $loc_row;
    }
}


Now, contained within one array "$customers" I have all the information that would be needed for displaying any type of information related to a customer or a customers location.

By doing having this feature, I could build the ability to do xPath searches within the base array. That would be nice.

Anyways, what do you all think?  Worth it or not?

Jim Lucas


Maybe I don't get the new concept, but what would be wrong with:

// START CODE //
$cid = null;
$customers = array();

while ( $row = fetch_assoc($res) ) {

    $cid = $row['cid'];
    $customers[$cid] = $row;
    $customers[$cid]['contact_locations'] = array();

    $SQL = "SELECT *
        FROM contact_locations
        WHERE c_id={$cid}";

    $loc_res = query($SQL);

    while ( $loc_row = fetch_assoc($loc_res) ) {
        $customers[$cid]['contact_locations'][] = $loc_row;
    }

}
// END CODE //

Now you can easily reference all of your customers by ID and get any of the data you want. I would actually just load the record I want from the database and not chew up all that memory, but this is just an example anyway.

I guess it could allow you to somewhat consolidate a two-dimensional array down to a single dimension. In order to use the data, you'd have to use array_keys() or something similar to use it though.

It's an interesting idea, but I don't know how practical it would be.

--
Ray Hauge
www.primateapplications.com

--- End Message ---

Reply via email to