OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 28 Jun 2004 09:14:50 -0000 Issue 2845

php-general-digest-helplists.php.net
Date: Mon Jun 28 2004 - 04:14:50 CDT


php-general Digest 28 Jun 2004 09:14:50 -0000 Issue 2845

Topics (messages 189114 through 189122):

New changes
        189114 by: Hitcho

Re: Construction
        189115 by: Paul Bissex
        189116 by: Michael Sims

Re: Crontab PHP Script
        189117 by: Ryan Schefke

Hierarchies and MySQL with PHP
        189118 by: Mattias Thorslund
        189119 by: Marek Kilimajer
        189120 by: Warren Vail
        189121 by: Mattias Thorslund
        189122 by: Mattias Thorslund

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


attached mail follows:


On Sat, 26 Jun 2004 20:51:58 -0700, Jason Davidson
<jason.davidsongmail.com> wrote:
>
> If you instantiate a child class, the parent class constructor is not
> called, is there a reason for this? anyone know of plans to change
> this at all, ....
> the obvious workaround is to call the parents constructor inside the
> childs constructor, but this seems kinda strange.

I think it's unlikely to change. PHP5 also works this way, though it
uses constructor methods named "__construct" (in addition to allowing
old-style constructors with the name of the class).

<?php
// PHP5

class Foo
  {
  function __construct()
    {
    $this->x = "data";
    }
  }

class Bar extends Foo
  {
  function __construct()
    {
    parent::__construct();
    $this->y = "more data";
    }
  }
?>

FWIW Python also requires child classes to call parent constructors
manually. Not sure what the justification is for this design decision
is, though, in either language. Anybody?

pb

--
paul bissex, e-scribe.com -- database-driven web development
413.585.8095
69.55.225.29
01061-0847
72°39'71"W 42°19'42"N

attached mail follows:


Paul Bissex wrote:
> FWIW Python also requires child classes to call parent constructors
> manually. Not sure what the justification is for this design decision
> is, though, in either language. Anybody?

Flexibility, I would guess. With PHP's current behavior one can:

(1) Call the parent constructor first, before the subclass constructor does
its work.
(2) Call the parent constructor last, after the subclass constructor does
its work.
(3) Call the parent constructor in the middle...doing some work before, and
then some work after. :)
(3) Pass through all of the subclass constructor's arguments to the parent
constructor unaltered.
(4) Change or filter some of the arguments that get passed to the parent
constuctor.
(5) Choose not to call the parent constructor at all.
(6) Many other things that I'm sure I'm overlooking...

If PHP called the parent constructor for you automagically, then how would
you implement the above options? PHP would have to choose one approach and
stick to it. I like the current behavior much better.

Forgive me if this has been mentioned in this thread previously, but PHP
does call the parent class constructor automatically if the subclass has no
constuctor, which does make sense....

attached mail follows:


Just some closure on my crontab question:

1 - Since my linux box has Plesk 7 (PSA) and it already had php installed on
it I guess php is installed in the "/usr/local/psa/admin/bin/php" directory.
Pretty sure atleast since the below crontab command is now executing my
script:
/usr/local/psa/admin/bin/php
/home/httpd/vhosts/tgwedding.com/httpdocs/tgwedding/crontab.php

I believe traditionally php is installed in "/usr/local/bin/php" but I could
be wrong...this is what was throwing me off.

2 - Tim, you were right, all stars will make the crontab run every minute on
my linux box

-----Original Message-----
From: Tim Traver [mailto:tt-listsimplenet.com]
Sent: Sunday, June 27, 2004 1:17 AM
To: Ryan Schefke; Php-General-Help; ryantriomfgroup.com
Subject: Re: [PHP] Crontab PHP Script

Not sure if this is different in linux, but usually the first parameter is
the minutes, and if you had 01 in it, that means that it would do it once
an hour (i.e. 12:01, 1:01, 2:01, etc...

They should all have stars to do it once a minute.

In freeBSD, it would look like this :
* * * * root /usr/local/bin/php
home/httpd/vhosts/tgwedding.com/httpdocs/tgwedding/crontab.php

Tim.

At 04:34 PM 6/26/2004, Ryan Schefke wrote:
>Hi,
>
>
>
>Can someone please give me some guidance. I'd like to run a php script
>every minute (in reality every night, but just testing). I've done some
>reading and found that a crontab is the best way to go (I think). I'm
using
>Plesk 7 on a Linux box and I have root access.
>
>
>
>I made a quick php script called crontab.php to email me.
>
>
>
>==============================================================
>
><?php //send email on domain
>
> /* subject */
>
> $str_subject = "crontab test";
>
>
>
> /* message */
>
> $messagecontent = "this is a test to
see
>if crontab working nightly\n\n";
>
>
>
> /* to */
>
> $to = "ryantriomfgroup.com";
>
>
>
> /* from */
>
> $headers .= "From: tgWedding
><developmenttriomfgroup.com>\r\n";
>
>
>
> /* bcc */
>
> // $headers .= "Bcc:
>developmenttriomfgroup.com\r\n";
>
>
>
> mail($to, $str_subject,
$messagecontent,
>$headers);
>
>?>
>
>
>
>
>
>Then I setup my crontab command as:
>/home/httpd/vhosts/tgwedding.com/httpdocs/tgwedding/crontab.php
><https://217.160.251.56:8443/sysuser/crontab_edit.php?cte_src=CTEJKgkqCSoJK
g
>kvaG9tZS9odHRwZC92aG9zdHMvdGd3ZWRkaW5nLmNvbS9odHRwZG9jcy90Z3dlZGRpbmcvY3Jvb
n
>RhYi5waHA=>
>
>
>
>
>
>I used " * " for every field except M, which I set to " 01 " to run every
>minute.
>
>
>
>
>
>It's not working...can someone guide me along and let me know what I've
done
>wrong.
>
>
>
>Thanks,
>
>Ryan

SimpleNet's Back !
http://www.simplenet.com

attached mail follows:


Hi,

I wonder what you think are the best (or "least worst") strategies to
store and retrieve hierarchial data (such as a "threaded" discussion or
a multi-level menu tree) in MySQL using PHP?

I have been using table structures where each row contains a parent
reference, such as:

Table Example:

Field name data type/db flags Coments
=================================================================
RowID int unsigned auto_increment not null (primary key)
ParentRowID int unsigned 0 (or NULL if at top
level)
Name varchar(50)

... which is OK for *defining* the hierarchy. However, it's a pain to
retrieve the data so that it can be displayed in a nice threaded/sorted
way, where children are sorted directly below their parents. I also
want the items to be nicely sorted within their own branch, of course.

On MS SQL, I successfully used stored procedures that employ temporary
tables and while statements and the like. That method is not available
in MySQL (yet), so I'll have to do a lot of the manipulation on the web
server instead, using PHP.

Any suggestions?

/Mattias

attached mail follows:


This should be of your interest:

http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047/

Mattias Thorslund wrote --- napísal::
> Hi,
>
> I wonder what you think are the best (or "least worst") strategies to
> store and retrieve hierarchial data (such as a "threaded" discussion or
> a multi-level menu tree) in MySQL using PHP?
>
> I have been using table structures where each row contains a parent
> reference, such as:
>
> Table Example:
>
> Field name data type/db flags Coments
> =================================================================
> RowID int unsigned auto_increment not null (primary key)
> ParentRowID int unsigned 0 (or NULL if at top
> level)
> Name varchar(50)
>
>
> ... which is OK for *defining* the hierarchy. However, it's a pain to
> retrieve the data so that it can be displayed in a nice threaded/sorted
> way, where children are sorted directly below their parents. I also
> want the items to be nicely sorted within their own branch, of course.
>
> On MS SQL, I successfully used stored procedures that employ temporary
> tables and while statements and the like. That method is not available
> in MySQL (yet), so I'll have to do a lot of the manipulation on the web
> server instead, using PHP.
>
> Any suggestions?
>
> /Mattias
>

attached mail follows:


I did one once where the key to the table was a string, and the string
contained 1 to n Node Numbers separated by a separator character.

"1"
"1.1"
"1.1.1"
"1.2"

select data from table where node between (1 and 2)

resulted in an entire limb of the tree being retrieved. Limitations were
the size of the string, depth of the tree (the string was truncated), and
the number of digits in each node number. Problem also with ordering node
numbers, node number 1 tended to be followed by node number 10, 11, 12, etc,
then number 2, until I pre-determined the number of leading zeros for each
node.

Not pretty, but it works well for small trees.

Warren Vail

-----Original Message-----
From: Mattias Thorslund [mailto:mattiasinreach.com]
Sent: Sunday, June 27, 2004 9:59 AM
To: PHP General Mail List
Subject: [PHP] Hierarchies and MySQL with PHP

Hi,

I wonder what you think are the best (or "least worst") strategies to
store and retrieve hierarchial data (such as a "threaded" discussion or
a multi-level menu tree) in MySQL using PHP?

I have been using table structures where each row contains a parent
reference, such as:

Table Example:

Field name data type/db flags Coments
=================================================================
RowID int unsigned auto_increment not null (primary key)
ParentRowID int unsigned 0 (or NULL if at top
level)
Name varchar(50)

... which is OK for *defining* the hierarchy. However, it's a pain to
retrieve the data so that it can be displayed in a nice threaded/sorted
way, where children are sorted directly below their parents. I also
want the items to be nicely sorted within their own branch, of course.

On MS SQL, I successfully used stored procedures that employ temporary
tables and while statements and the like. That method is not available
in MySQL (yet), so I'll have to do a lot of the manipulation on the web
server instead, using PHP.

Any suggestions?

/Mattias

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

attached mail follows:


Marek Kilimajer wrote:

> This should be of your interest:
>
> http://www.evolt.org/article/Four_ways_to_work_with_hierarchical_data/17/4047/
>
>
Indeed! The "flat table model" is simple, efficient and - I think -
sufficient. Thanks!

I also found this article which explains the "fourth" method not really
described above, despite the title:
http://www.sitepoint.com/article/hierarchical-data-database/

That method is a bit more complicated but it also allows you to
determine the (total) number of child nodes of a node, without an extra
SQL query.

/Mattias

attached mail follows:


Warren Vail wrote:

>I did one once where the key to the table was a string, and the string
>contained 1 to n Node Numbers separated by a separator character.
>
>"1"
>"1.1"
>"1.1.1"
>"1.2"
>
>select data from table where node between (1 and 2)
>
>resulted in an entire limb of the tree being retrieved. Limitations were
>the size of the string, depth of the tree (the string was truncated), and
>the number of digits in each node number. Problem also with ordering node
>numbers, node number 1 tended to be followed by node number 10, 11, 12, etc,
>then number 2, until I pre-determined the number of leading zeros for each
>node.
>
>Not pretty, but it works well for small trees.
>
>Warren Vail
>
>

Been there, done that, ran into the same limitations :-)

The "flat table" solution in the article suggested by Marek keeps a
running "display order" integer column, updated only when items are
added (or removed, but that's not strictly necessary if you don't mind
holes in the sequence). When inserting a new item, it gets the display
order value of the parent + 1, and the following items have their
display order incremented by 1. Simple. There's also an "indentation
level" column, which is simple enough to maintain.

/Mattias