php-general Digest 31 Jan 2007 15:27:03 -0000 Issue 4600

Topics (messages 248077 through 248086):

Re: What search algorithm does in_array() use?
        248077 by: Ligaya A. Turmelle

regarding ereg() problem
        248078 by: jekillen
        248080 by: Jim Lucas

Re: Need tool to graphically show all includes/requires -- first version 
Announcement
        248079 by: Daevid Vincent

Re: Help wtih a query?
        248081 by: Satyam

Re: Parsing mail file [RESOLVED]
        248082 by: Pierre Pintaric

Re: SOLVED convert date to reversed date
        248083 by: Reinhart Viane

Need sql-editor
        248084 by: Niklas Karlsson

Re: Suggestions of GPL plugin-system?
        248085 by: Ivo F.A.C. Fokkema

Re: Socket problem plz read.
        248086 by: Scripter47

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Don't use a theta join - use a left, right or inner preferably with ANSI
syntax and make sure you indexes are set up correctly - this shouldn't
take very long to execute at all.

SELECT d.account 
FROM data d
  INNER JOIN accesslist a 
    USING account  (or ON d.account=a.account)
WHERE a.username='username'

Respectfully,
Ligaya Turmelle
Systems Analyst
Guamcell Communications
Phone: (671)689-2377 
-----Original Message-----
From: Ken Dozier [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 31, 2007 6:31 AM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net; 'Gregory Beaver'
Subject: RE: [PHP] What search algorithm does in_array() use?

Thanks to all for your input, guys.

Regarding the construction of the SQL query, I would love to try it with
SUBSELECTs; but, alas, we are using RHEL 3 which ships with MySQL 3.23.
I don't think RH supports any 4.0 or later versions of MySQL on RHEL 3,
so I'm stuck with 3.23 for the time being.  I had tried a query like
this:

SELECT d.account FROM data AS d, accesslist AS a WHERE
d.account=a.account AND a.username='username'

but it also took quite a bit of time.  Since the problem would appear
for only a few users, I may have to simply hard code a workaround for
the time being and then come back to it later.

Thanks again for all of your help.

Ken.

-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Monday, January 29, 2007 6:13 PM
To: Ken Dozier
Cc: php-general@lists.php.net
Subject: Re: [PHP] What search algorithm does in_array() use?

On Mon, January 29, 2007 11:20 am, Ken Dozier wrote:
> Does in_array() use a search algorithm (i.e., binary search), or does 
> it check sequentially each element in the array?

Since there is no guarantee that the elements are in any particular
order, it almost has to be sequential...

> I am using in_array() within a while{} loop to check query results 
> against an access-list array to produce a third array containing items

> that successfully passed the comparison test.  Because the two 
> starting arrays in the worst-case scenario can have 8,000 items each, 
> the loop is timing out.
> Advice or alternative methods are appreciated.
>
> Code Sample:
> <?php
> function check_results($results, $access_list) { # Check for $results 
> in array $access_list and
>   # add matches to array $match.
>
>   $result = false;
>   $match = array();
>
>   while ($r = mysql_fetch_row($results))
>   { if ( in_array($r[0], $access_list) )
>     { $match[] = $r; }
>   }
>
>   if ( count($match) > 0 ) { $result = $match; }
>
>   return $result;
> }
> ?>

Ideal #1:
Figure out how to write an SQL query to find what's in the DB, and don't
do any search in PHP at all.

Ideal #2:
Put the values in as keys, and use http://php.net/isset This will "hash"
the values and have an O(1) lookup, I think.
Only works if you know the uniqueness of the values to be searched, or
don't care about duplicates.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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

--- End Message ---
--- Begin Message ---
Hi again;
(Blush)
I just did noticed that I
did not mask out the
two dots:
$x = ereg("<route name='$to' x='\.\./(.*)/in' rec='.*' />", $get_route, $m);
I am trying again......
I still get the same result
jk/in' rec='a_378e6dc4.xml' />
JK

--- End Message ---
--- Begin Message ---
jekillen wrote:
Hi again;
(Blush)
I just did noticed that I
did not mask out the
two dots:
$x = ereg("<route name='$to' x='\.\./(.*)/in' rec='.*' />", $get_route, $m);
I am trying again......
I still get the same result
jk/in' rec='a_378e6dc4.xml' />
JK


Tell a little more about what you are trying to do?

Example input and expected results ???

Jim

--- End Message ---
--- Begin Message ---
Impossible! HAH!

So here's a first stab at this.
http://daevid.com/examples/include_tree.zip

It's not very pretty (yet), but should illustrate where I'm going with it.
Next step is to make it a nice tree view in a .html page or something. I'm
not quite sure what or how I want to do that just yet, but it's quite useful
as it is. Simply redirect the output to a file.

It handles sane define('ROOTPATH', '/myroot/') format substitutions. It does
not handle the other goofy function/variable example given below. I don't
think that's very real-world.

# ./it.php --print_tree --parse_tree --debug

index.php
/includes/
   global.inc.php

Processing: /myroot/tools/include_tree/example/index.php
Processing: /myroot/tools/include_tree/example/includes/global.inc.php
Array
(
    [branding.inc.php] => item Object
        (
            [path] => /
            [file] => branding.inc.php
            [realpath] => .
            [includedByArray] => Array
                (
                    [0] => /includes/global.inc.php
                )

            [requiresArray] => Array
                (
                )

        )

    [db.inc.php] => item Object
        (
            [path] => /myroot/includes
            [file] => db.inc.php
            [realpath] => ROOTPATH."/includes
            [includedByArray] => Array
                (
                    [0] => /index.php
                    [1] => /includes/global.inc.php
                )

            [requiresArray] => Array
                (
                )

        )

    [global.inc.php] => item Object
        (
            [path] => /includes
            [file] => global.inc.php
            [realpath] => /myroot/tools/include_tree/example/includes
            [includedByArray] => Array
                (
                    [0] => /index.php
                )

            [requiresArray] => Array
                (
                    [0] => /locale_default.inc.php
                    [1] => /branding.inc.php
                    [2] => /myroot/includes/db.inc.php
                    [3] => /log.php
                    [4] => /myroot/includes/universal.inc.php
                    [5] => /classes/persistent_variables.php
                )

        )
...

DÆVID  

> -----Original Message-----
> From: Roman Neuhauser [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, January 20, 2007 4:46 AM
> To: Daevid Vincent
> Cc: 'PHP General'
> Subject: Re: [PHP] Need tool to graphically show all includes/requires
> 
> # [EMAIL PROTECTED] / 2007-01-19 16:52:49 -0800:
> > We have a fairly complex product that is all PHP based GUI.
> > 
> > We're in need of some kind of "graphical tool" (web, stand 
> alone, windows,
> > linux, osx whatever) that will take a directory tree, 
> recursively traverse
> > all the files, look for 'includes' and 'requires' (and the 
> _once versions
> > too) and then map them out so we can see what files are 
> calling what and
> > where.
> 
> That's impossible to tell exactly without running the software you're
> studying. What would you map this to?
> 
> function include_($file) { include $file; }
> 
> Or this?
> 
> define('FOO_INLCUDE_DIR', '/some/path');
> include FOO_INLCUDE_DIR . '/file.php';
> 
> The recursive part is easy:
> 
> find $topsrcdir -name \*.php -print0 | xargs -0n1 
> processing-script-for-one-file


"Some people, when confronted with a problem, think 'I know, I'll use XML.'"
Now they have two problems. 

--- End Message ---
--- Begin Message --- ----- Original Message ----- From: "Jon Anderson" <[EMAIL PROTECTED]>
To: "Skip Evans" <[EMAIL PROTECTED]>
Cc: "PHP-General" <php-general@lists.php.net>
Sent: Tuesday, January 30, 2007 11:46 PM
Subject: Re: [PHP] Help wtih a query?


Wrong list. Putting "$sql=..." in there doesn't make it a PHP question. ;-)

Skip Evans wrote:
Is that what the left/right joins do???
Yea. LEFT JOIN will give you NULL entries in the left joined table, so you'd just have to say WHERE ISNULL(<left joined table>.<some field in that table>). Of course, you'll need to do the right JOINs in there for that to work.

Personally, I think that implicit joins are sloppy, so I would suggest using JOIN with ON or USING...but I suppose that's a preference thing, and some (all?) might disagree with me.


SQL engines have many techniques to improve the performance of the queries, with dozens of scholarly papers backing each slight improvement. The more the SQL engine knows about your intentions, the better chances it has to apply the best techniques to improve the performance of your query. For a particular engine, only a subset of all these tricks might be implemented so little might be gained from writing queries this way instead of that way and this might change with each version but it still holds that the chances for better performance improve if you make it clear what you want, eventually.

Satyam



jon

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


--- End Message ---
--- Begin Message ---
Finally, after a long course about the fishing philosophy :-)

A private discussion with Jon give me a very good way to find a solution.
I would to share it with guys who need it :
PECL mailparse package: http://pecl.php.net/package/mailparse

It parses mail files with attachments (rfc822 and rfc2045 compliant messages).

Good luck


Mauro Lorenzutti a écrit :
Hi Pierre,

I have the same problem: I'm searching a function to parse an email
file. I found this one:

http://pear.php.net/package/Net_IMAP/

I think that you can extract the code you need from the function
getParsedHeaders.

Regards,
 Mauro Lorenzutti


e-mail:  [EMAIL PROTECTED]

---------------------------------------------------------
WEBFORMAT srl | Corte Europa, 12 | I-33097 SPILIMBERGO PN
     Tel +39-0427-926.389  --  Fax +39-0427-927.653
       [EMAIL PROTECTED]  --  www.webformat.com
---------------------------------------------------------


--- End Message ---
--- Begin Message ---
Thx All

-----Oorspronkelijk bericht-----
Van: Jim Lucas [mailto:[EMAIL PROTECTED] 
Verzonden: dinsdag 30 januari 2007 16:52
Aan: Jim Lucas
CC: Arpad Ray; [EMAIL PROTECTED]; php-general@lists.php.net
Onderwerp: Re: [PHP] convert date to reversed date

Jim Lucas wrote:
> Arpad Ray wrote:
>> $filename = implode(array_reverse(explode('/', $value)));

I should have checked before I wrote.  It does work, but through me off, 
didn't realize that the first arg was optional.  Sorry


> I think you ment
> 
> $filename = implode('', array_reverse(explode('/', $value)));
> 
>>
>> Arpad
>>
>> Reinhart Viane wrote:
>>> Is this a good way to convert 01/02/2007 to 20070201
>>>
>>>  
>>>
>>> $value='01/02/2007';
>>>
>>> list($day, $month, $year) = split('[/.-]', $value);
>>>
>>> $filename=$year.''.$month.''.$day;
>>>
>>>  
>>>
>>> It does work but i would like to verify if there are no better, more 
>>> logical
>>> ways to do this.
>>>
>>> Thanks in advance
>>>
>>>
>>>   
>>
> 
> 


-- 
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different 
strings. But there are times for you and me when all such things agree.

- Rush

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

--- End Message ---
--- Begin Message ---
Hello everyone

 

I need a good sql-editor where I can write sqlcode. The problem is that I
don't have rights to list tables, functions and so on. Now I use EMS Sql
Manger 2005, and if I want to write and execute sqlcode I need access to the
system tables, and I don't have it on this database.

 

So, I need a sqlmanger that I cant write and execute sqlcode and don't have
the access, and where a can view the result nicely.

 

Hope you understand, my English isn't on top :-)

 

// Niklas   

 


--- End Message ---
--- Begin Message ---
Thanks everyone for the useful input. I've looked around a bit using the
various links and info that I got. The Gallery2 documentation on the
modules is far from transparent to me, and the idea of having a general
module class that needs to get extended by the module doesn't appeal to
me either. I really like the Drupal system with it's "hooks" and I like
the idea of having my project communicate with various modules through
these hooks. The whole system with the API is kinda big though, and right
now I don't plan to give modules control over my menu or anything.

So I guess, inspired by the Drupal system, I'm going to create a much
smaller system that I will implement myself...

Thanks again!

Ivo

--- End Message ---
--- Begin Message ---
I'm making a simple socket server that just receive some data, and then
send some data back again to the client.

EDIT:
I forgot to tell that i need help!

I have search around for hours now, and the examples are always not what
I needed :(

the program is written in Python, if that helps, and is something like this
<code>
# Set the socket parameters
host = "http://localhost/in/sql.php";
port = 10000
buf = 10000
addr = (host,port)

# Create socket
UDPSock = socket(AF_INET, SOCK_DGRAM)

# Send messages:

# Loop
while (1):
        # userinput
        data = raw_input('>> ')
        if not data:
                break
        else:
                # Send to the PHP page
                if(UDPSock.sendto(data,addr)):
                        print "Sending message '",data,"'....."

# Close socket
UDPSock.close()
</code>

it is a program that send data by sockets, (not port 80)

It has to a simple solution :)

plz ask for more information.




--
  _________            .__        __                  ______________
 /   _____/ ___________|__|______/  |_  ___________  /  |  \______  \
 \_____  \_/ ___\_  __ \  \____ \   __\/ __ \_  __ \/   |  |_  /    /
 /        \  \___|  | \/  |  |_> >  | \  ___/|  | \/    ^   / /    /
/_______  /\___  >__|  |__|   __/|__|  \___  >__|  \____   | /____/
        \/     \/         |__|             \/           |__|

--- End Message ---

Reply via email to