php-general Digest 24 May 2009 10:55:22 -0000 Issue 6138

Topics (messages 293036 through 293058):

Re: Rogue 'if - elseif' code
        293036 by: Nathan Rixham
        293043 by: LinuxManMikeC

Re: urgent CSS question
        293037 by: LinuxManMikeC

templating engine options
        293038 by: Nathan Rixham
        293039 by: LinuxManMikeC
        293040 by: Kevin Waterson
        293041 by: Nathan Rixham
        293042 by: Nathan Rixham
        293045 by: Eddie Drapkin

Re: <table>-less layouts; Ideas welcome
        293044 by: Paul M Foster
        293046 by: Michael A. Peters
        293058 by: Ashley Sheridan

change server time
        293047 by: Sumit Sharma
        293050 by: Michael A. Peters

conditional classes
        293048 by: kranthi
        293049 by: LinuxManMikeC
        293052 by: kranthi
        293055 by: Nathan Rixham

General Web Development Editor/IDE
        293051 by: Casey
        293053 by: kranthi
        293054 by: Lester Caine
        293056 by: Nathan Rixham

php dev environment
        293057 by: Nathan Rixham

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 ---
LinuxManMikeC wrote:
On Fri, May 22, 2009 at 2:50 PM, Nathan Rixham <[email protected]> wrote:
Andre Dubuc wrote:
Hi,

I'm having problems with a chunk of 'rogue' code that does not perform as
expected (it does not pass the expected date, but an empty value). Most of
the time, it works - so I'm wondering whether it might be a browser issue.
(The latest failure occurred with Firfeox 3.0 browser on an NT 5.1 OS.) The
code is stored on an Unix server, running PHP 5.x.
I've isolated it down to multiple if - elseif statements that check long
dates for completeness, "day" "month" and "year". The code then applies it
results printing one of following: the full date - 22 May 2009, month-year -
May 2009, or just the year, 2009. My question is whether the ORDER of
checking is important, i.e, whether checking for the null sets BEFORE full
sets or AFTER.
I've added debugging code to be able to get the raw POST values so I can
manually enter it into the db, but I would really appreciate some help here.
The code is old -- I wrote it seven years ago, and had worked well until I
modified it, but I no longer have the original working code.
[The first conditional line of the code checks whether the user has
entered the birth date, then it checks for the death date. The $_SESSION
stuff is debugging code.]


<?php


       $yd = $_POST['death'];
       $yb =  $_POST['birth'];


       if ($_POST['bday'] == "Day" && $_POST['bmonth'] == "Month" &&
$_POST['birth'] == "Year") {


               if ($_POST['dday'] != "Day" && $_POST['dmonth'] != "Month"
&& $_POST['death'] != "Year") {

                       $_POST['rdod'] = ("{$_POST['dday']}
{$_POST['dmonth']} {$_POST['death']}");
                       $_SESSION['ALL1rdod'] = $_POST['rdod'];

               }


               elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] ==
"Month" && $_POST['death'] != "Year") {

                       $_POST['rdod'] = $_POST['death'];
                       $_SESSION['YEAR1rdod'] = $_POST['rdod'];

               }


               elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] !=
"Month" && $_POST['death'] != "Year") {

                       $_POST['rdod'] = ("{$_POST['dmonth']}
{$_POST['death']}");
                       $_SESSION['MONTHYEAR1rdod'] = $_POST['rdod'];

               }


               $_SESSION['Sdebugdod1'] = "{$_POST['dday']}
{$_POST['dmonth']} {$_POST['death']}";

       }


               else {


                       if ($yd > $yb) {


                               if ($_POST['bday'] != "Day" &&
$_POST['bmonth'] != "Month" && $_POST['birth'] != "Year") {

                                       $_POST['rdob'] = ("{$_POST['bday']}
{$_POST['bmonth']} {$_POST['birth']}");

                               }


                               elseif ($_POST['bday'] == "Day" &&
$_POST['bmonth'] == "Month" && $_POST['birth'] != "Year") {

                                       $_POST['rdob'] = $_POST['birth'];

                               }


                               elseif ($_POST['bday'] == "Day" &&
$_POST['bmonth'] != "Month" && $_POST['birth'] != "Year") {

                                       $_POST['rdob'] =
("{$_POST['bmonth']} {$_POST['birth']}");

                               }



                               if ($_POST['dday'] != "Day" &&
$_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {

                                       $_POST['rdod'] = ("{$_POST['dday']}
{$_POST['dmonth']} {$_POST['death']}");
                                       $_SESSION['ALL2rdod'] =
$_POST['rdod'];

                               }


                               elseif ($_POST['dday'] == "Day" &&
$_POST['dmonth'] == "Month" && $_POST['death'] != "Year") {

                                       $_POST['rdod'] = $_POST['death'];
                                       $_SESSION['YEAR2rdod'] =
$_POST['rdod'];

                               }


                               elseif ($_POST['dday'] == "Day" &&
$_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {

                                       $_POST['rdod'] =
("{$_POST['dmonth']} {$_POST['death']}");
                                       $_SESSION['MONTHYEAR2rdod'] =
$_POST['rdod'];

                               }


                               $_SESSION['Sdebugdod2'] = "{$_POST['dday']}
{$_POST['dmonth']} {$_POST['death']}";



                       }


?>

Any help or pointers would be greatly appreciated!

Tia,
Andre

makes no sense at all to me without some decent variable names "rdod"? -
would also need the form to be honest, and a description of the
functionality needed.

one thing i can say is that you have a closing bracket missing at the end
and your $_SESSION['Sdebugdod2'] appears to be in the wrong place
(to solve both these try sticking a } before $_SESSION['Sdebugdod2']

really though, change the names in the form to something more descriptive

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



Yes, additional context would be great.  Also, it looks like Andre is
storing all his variables in $_POST, making it even harder to tell
what is from the HTML form and what is a programer's variable.  Andre,
IF I'm interpreting your explanation and code right, you are accepting
an entire date in a single field and it could be complete or partial.
If this is the case, you could much more easily validate the field
with a few regex patterns.  If you still need to work with the
individual components, either have separate date component fields in
your form, or use preg_split($regex,$date,PREG_SPLIT_DELIM_CAPTURE) to
parse the single input field for the date components.  For preg_split,
make your regex match valid date components and combined with the
DELIM_CAPTURE argument it will return an array of the date components.
 From there, do any further validation you need on the individual
components.  This would significantly shorten your code and make it
easier to read another 7 years from now.  And for goodness sake, I
hope you comment your code these days.


i.e. "that codes crap mate"

--- End Message ---
--- Begin Message ---
On Sat, May 23, 2009 at 4:36 PM, Andre Dubuc <[email protected]> wrote:
> On May 23, 2009, you wrote:
>> On Fri, May 22, 2009 at 2:50 PM, Nathan Rixham <[email protected]> wrote:
>> > Andre Dubuc wrote:
>> >> Hi,
>> >>
>> >> I'm having problems with a chunk of 'rogue' code that does not perform
>> >> as expected (it does not pass the expected date, but an empty value).
>> >> Most of the time, it works - so I'm wondering whether it might be a
>> >> browser issue. (The latest failure occurred with Firfeox 3.0 browser on
>> >> an NT 5.1 OS.) The code is stored on an Unix server, running PHP 5.x.
>> >> I've isolated it down to multiple if - elseif statements that check long
>> >> dates for completeness, "day" "month" and "year". The code then applies
>> >> it results printing one of following: the full date - 22 May 2009,
>> >> month-year - May 2009, or just the year, 2009. My question is whether
>> >> the ORDER of checking is important, i.e, whether checking for the null
>> >> sets BEFORE full sets or AFTER.
>> >> I've added debugging code to be able to get the raw POST values so I can
>> >> manually enter it into the db, but I would really appreciate some help
>> >> here. The code is old -- I wrote it seven years ago, and had worked well
>> >> until I modified it, but I no longer have the original working code.
>> >> [The first conditional line of the code checks whether the user has
>> >> entered the birth date, then it checks for the death date. The $_SESSION
>> >> stuff is debugging code.]
>> >>
>> >>
>> >> <?php
>> >>
>> >>
>> >>        $yd = $_POST['death'];
>> >>        $yb =  $_POST['birth'];
>> >>
>> >>
>> >>        if ($_POST['bday'] == "Day" && $_POST['bmonth'] == "Month" &&
>> >> $_POST['birth'] == "Year") {
>> >>
>> >>
>> >>                if ($_POST['dday'] != "Day" && $_POST['dmonth'] !=
>> >> "Month" && $_POST['death'] != "Year") {
>> >>
>> >>                        $_POST['rdod'] = ("{$_POST['dday']}
>> >> {$_POST['dmonth']} {$_POST['death']}");
>> >>                        $_SESSION['ALL1rdod'] = $_POST['rdod'];
>> >>
>> >>                }
>> >>
>> >>
>> >>                elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] ==
>> >> "Month" && $_POST['death'] != "Year") {
>> >>
>> >>                        $_POST['rdod'] = $_POST['death'];
>> >>                        $_SESSION['YEAR1rdod'] = $_POST['rdod'];
>> >>
>> >>                }
>> >>
>> >>
>> >>                elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] !=
>> >> "Month" && $_POST['death'] != "Year") {
>> >>
>> >>                        $_POST['rdod'] = ("{$_POST['dmonth']}
>> >> {$_POST['death']}");
>> >>                        $_SESSION['MONTHYEAR1rdod'] = $_POST['rdod'];
>> >>
>> >>                }
>> >>
>> >>
>> >>                $_SESSION['Sdebugdod1'] = "{$_POST['dday']}
>> >> {$_POST['dmonth']} {$_POST['death']}";
>> >>
>> >>        }
>> >>
>> >>
>> >>                else {
>> >>
>> >>
>> >>                        if ($yd > $yb) {
>> >>
>> >>
>> >>                                if ($_POST['bday'] != "Day" &&
>> >> $_POST['bmonth'] != "Month" && $_POST['birth'] != "Year") {
>> >>
>> >>                                        $_POST['rdob'] =
>> >> ("{$_POST['bday']} {$_POST['bmonth']} {$_POST['birth']}");
>> >>
>> >>                                }
>> >>
>> >>
>> >>                                elseif ($_POST['bday'] == "Day" &&
>> >> $_POST['bmonth'] == "Month" && $_POST['birth'] != "Year") {
>> >>
>> >>                                        $_POST['rdob'] = $_POST['birth'];
>> >>
>> >>                                }
>> >>
>> >>
>> >>                                elseif ($_POST['bday'] == "Day" &&
>> >> $_POST['bmonth'] != "Month" && $_POST['birth'] != "Year") {
>> >>
>> >>                                        $_POST['rdob'] =
>> >> ("{$_POST['bmonth']} {$_POST['birth']}");
>> >>
>> >>                                }
>> >>
>> >>
>> >>
>> >>                                if ($_POST['dday'] != "Day" &&
>> >> $_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {
>> >>
>> >>                                        $_POST['rdod'] =
>> >> ("{$_POST['dday']} {$_POST['dmonth']} {$_POST['death']}");
>> >>                                        $_SESSION['ALL2rdod'] =
>> >> $_POST['rdod'];
>> >>
>> >>                                }
>> >>
>> >>
>> >>                                elseif ($_POST['dday'] == "Day" &&
>> >> $_POST['dmonth'] == "Month" && $_POST['death'] != "Year") {
>> >>
>> >>                                        $_POST['rdod'] = $_POST['death'];
>> >>                                        $_SESSION['YEAR2rdod'] =
>> >> $_POST['rdod'];
>> >>
>> >>                                }
>> >>
>> >>
>> >>                                elseif ($_POST['dday'] == "Day" &&
>> >> $_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {
>> >>
>> >>                                        $_POST['rdod'] =
>> >> ("{$_POST['dmonth']} {$_POST['death']}");
>> >>                                        $_SESSION['MONTHYEAR2rdod'] =
>> >> $_POST['rdod'];
>> >>
>> >>                                }
>> >>
>> >>
>> >>                                $_SESSION['Sdebugdod2'] =
>> >> "{$_POST['dday']} {$_POST['dmonth']} {$_POST['death']}";
>> >>
>> >>
>> >>
>> >>                        }
>> >>
>> >>
>> >> ?>
>> >>
>> >> Any help or pointers would be greatly appreciated!
>> >>
>> >> Tia,
>> >> Andre
>> >
>> > makes no sense at all to me without some decent variable names "rdod"? -
>> > would also need the form to be honest, and a description of the
>> > functionality needed.
>> >
>> > one thing i can say is that you have a closing bracket missing at the end
>> > and your $_SESSION['Sdebugdod2'] appears to be in the wrong place
>> > (to solve both these try sticking a } before $_SESSION['Sdebugdod2']
>> >
>> > really though, change the names in the form to something more descriptive
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> Yes, additional context would be great.  Also, it looks like Andre is
>> storing all his variables in $_POST, making it even harder to tell
>> what is from the HTML form and what is a programer's variable.  Andre,
>> IF I'm interpreting your explanation and code right, you are accepting
>> an entire date in a single field and it could be complete or partial.
>> If this is the case, you could much more easily validate the field
>> with a few regex patterns.  If you still need to work with the
>> individual components, either have separate date component fields in
>> your form, or use preg_split($regex,$date,PREG_SPLIT_DELIM_CAPTURE) to
>> parse the single input field for the date components.  For preg_split,
>> make your regex match valid date components and combined with the
>> DELIM_CAPTURE argument it will return an array of the date components.
>>  From there, do any further validation you need on the individual
>> components.  This would significantly shorten your code and make it
>> easier to read another 7 years from now.  And for goodness sake, I
>> hope you comment your code these days.
>
>
> Nope, I'm not 'storing' all my variables in $_POST -- this is the first
> processing from an input page where the input variables are passed as $_POST
> variables (since they have not been evaluated/sanitized yet).
>
> The input for the date of birth/death fields come from drop-down three section
> HTML selects - the resulting data may output a complete or partial date.
>
> I need to work with individual components -- regex would be overkill here and
> result in even longer code. The code is quite simple once you understand that
> the Date of Birth is optional, but the Date of Death is mandatory. The prefix
> for Date of Birth 'b' as in 'bday' bmonth' 'byear', the prefix for Date of
> Daeth is 'd'.
>
> As far as readability, I have no probs wih it - and since I shall be the only
> one ever working with it, I'm sorry it was a problem for you. Actually, this
> part of the code for the page I felt didn't need any commenting: it was
> self-explanatory (at least it is to me. Later code is very heavily commented
> because it becomes very complex with multiple conditionals.).
>
> However, the main question that I had asked, and is still unanswered: is the
> ORDER of condtionals significant? Should one check for NULL first or last, or
> check for the complete dat then move through various combos until NULL?
>
> I must say I am surprised by the tone of first responses to my question. I
> guess the 'temper of the times'  has changed somewhat since I was last on.
> Pity.
>
> Thanks for replying.
> Andre
>
> Btw, I've gone off list, so don't feel obligated to reply.
>
>

1 - You're not the only one "working on it" once you post it to a
mailing list asking for help.

2 - $_POST['rdod'] and $_POST['rdob'] sure look like they're being
used as intermediate variables.

3 - That little detail of 3 select fields made all the difference in
understanding what you're trying to accomplish in the code.  A great
place to note such things is in... a comment...

Anyway, my answer to your base question is... I always check for null
first.  If there is no data, no point in doing anything else on it.

Aside from that, I agree regex isn't right, now that I understand the
application better.  Regardless, I think this section of code still
seems way too complicated, redundant, and convoluted for what you're
trying to accomplish.  With a chain of if-elseif statements like that
its terribly inefficient and the redundant conditionals makes problems
hard to spot.  Please consider the following logic:

$rdob = '';

if (isset($_POST['birth']) && $_POST['birth'] != 'Year') {
    $rdob = $_POST['birth'];
    if (isset($_POST['bmonth']) && $_POST['bmonth'] != 'Month') {
        $rdob = $_POST['bmonth'] . ' ' . $rdob;
        if (isset($_POST['bday']) && $_POST['bday'] != 'Day') {
            $rdob .= $_POST['bday'] . ' ' . $rdob;
        }
    }
}

Each field is only processed once while building the $rdob string.
When a required component doesn't check out it stops.  Now if you need
to process all 3 components, you might want to do the test separately
and store the boolean result for use later.  That way you can reuse
the test results and only have to edit the logic in one place.  As far
as those multiple session vars, I have no idea how you plan to use
them, but there has got to be a better way.  Modify this logic to fit
your needs if you wish.

Glancing at it, I don't notice where the problem you're experiencing
might be in the section of code you provided.  It might be in a
completely different place for all we know.  Its probably a simple
typo that's hard to find because of how it was written.  Anyway, thats
all I have to offer.  Good luck.

--- End Message ---
--- Begin Message ---
Maybe there is another CSS rule that also matches the same context and
overrides parts of the #frame1 rule, but didn't match when using the
old #frame rule.  Just my two cents.

On Fri, May 22, 2009 at 7:15 PM, PJ <[email protected]> wrote:
> Benjamin Hawkes-Lewis wrote:
>> On 22/5/09 20:31, PJ wrote:
>>> They may have different names, but does that change their functionality?
>>
>> Potentially, yes!
>>
>> A selector including #frame will no longer match if "id" is changed to
>> "frame1", and vice versa.
>>
>>> They are identical except for the "1" in the title of the id. So, if I
>>> change the one id to the other in the same code, I don't understand why
>>> the formatting would change?
>>
>> These descriptions are still far too vague and ambiguous. Please link
>> to two test cases:
>>
>> 1) Effectively showing "frame1".
>>
>> 2) Effectively showing "frame".
>>
>> that illustrate the problem you're talking about.
>>
>>> Obviously, the parents and the children
>>> have not changed unless there's some weird hanky-panky going on.
>>
>> Without seeing test cases, nothing is obvious.
>>
>> > Or do I have to make a new css file for every page
>>
>> Only if you're doing it wrong. :)
>>
>>> And to follow the logic here, if I create a different id and in the
>>> end it turns out to be identical to the original "frame" except for the
>>> name, shouldn't it function the same.
>>
>> That depends on:
>>
>> 1) The contents of your CSS file, which I can't see.
>> 2) Whether you've made any errors when modifying your HTML, which I
>> can't see either.
>>
>> If you provided test cases, I could see these things and answer your
>> questions.
>>
>> Trying to describe the problem rather than /showing/ the problem is
>> very inefficient.
>>
>> --
>> Benjamin Hawkes-Lewis
>>
> Ok, I'm glad the there are some people out there  who want to get down
> to the bottom of things.
> I can attach or maybe put up a link on a website where you can look at
> the code and the css.
> But regardless of any test caste, nothing changes the fact that whatever
> the html code, whatever the php code, these are sonstant and nothing is
> changed. Switch between id frame and id frame1 and things change.
> nothnig, I meant, nothing is changed in between. The difference is in
> the css, and nothing else.
> I'll post the location later tonight or , more likely, tomorrow am.
> zzzzzzzzz
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- [email protected]
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Hi All,

Just a quick one, can anybody recommend any decent templating engines other than smarty.

I've got no problem with smarty and it does the job - but if there is something newer and lighter out there that I'm missing then I'd be a fool not to at least consider it!

can't be part of a framework, (or if it is easily extracted with no framework dependencies), and not xslt (love xslt, but not many designers do!).

many regards,

Nathan

--- End Message ---
--- Begin Message ---
On Sat, May 23, 2009 at 4:21 PM, Nathan Rixham <[email protected]> wrote:
> Hi All,
>
> Just a quick one, can anybody recommend any decent templating engines other
> than smarty.
>
> I've got no problem with smarty and it does the job - but if there is
> something newer and lighter out there that I'm missing then I'd be a fool
> not to at least consider it!
>
> can't be part of a framework, (or if it is easily extracted with no
> framework dependencies), and not xslt (love xslt, but not many designers
> do!).
>
> many regards,
>
> Nathan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I was recently researching template engines for a small in-house
project, with a bias toward simple and lightweight.  I found this
interesting article in my search.  I think its worth considering if
you don't need all the bells and whistles of the big template engines.
 Simple and elegant.
http://www.massassi.com/php/articles/template_engines/

--- End Message ---
--- Begin Message ---
On Sat, 2009-05-23 at 23:21 +0100, Nathan Rixham wrote:
> Hi All,
> 
> Just a quick one, can anybody recommend any decent templating engines 
> other than smarty.
> 
> I've got no problem with smarty and it does the job - but if there is 
> something newer and lighter out there that I'm missing then I'd be a 
> fool not to at least consider it!
> 
> can't be part of a framework, (or if it is easily extracted with no 
> framework dependencies), and not xslt (love xslt, but not many designers 
> do!).

eZ Components
Use just the template component

http://ezcomponents.org

Kevin
http://phpro.org



--- End Message ---
--- Begin Message ---
Kevin Waterson wrote:
On Sat, 2009-05-23 at 23:21 +0100, Nathan Rixham wrote:
Hi All,

Just a quick one, can anybody recommend any decent templating engines other than smarty.

I've got no problem with smarty and it does the job - but if there is something newer and lighter out there that I'm missing then I'd be a fool not to at least consider it!

can't be part of a framework, (or if it is easily extracted with no framework dependencies), and not xslt (love xslt, but not many designers do!).

eZ Components
Use just the template component

http://ezcomponents.org

Kevin
http://phpro.org



cheers for that kevin, does look good; kind of smarty++ - will need to give it a try out!
--- End Message ---
--- Begin Message ---
LinuxManMikeC wrote:
On Sat, May 23, 2009 at 4:21 PM, Nathan Rixham <[email protected]> wrote:
Hi All,

Just a quick one, can anybody recommend any decent templating engines other
than smarty.

I've got no problem with smarty and it does the job - but if there is
something newer and lighter out there that I'm missing then I'd be a fool
not to at least consider it!

can't be part of a framework, (or if it is easily extracted with no
framework dependencies), and not xslt (love xslt, but not many designers
do!).

many regards,

Nathan

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



I was recently researching template engines for a small in-house
project, with a bias toward simple and lightweight.  I found this
interesting article in my search.  I think its worth considering if
you don't need all the bells and whistles of the big template engines.
 Simple and elegant.
http://www.massassi.com/php/articles/template_engines/

cheers, it certainly is simple and elegant - however a bit too simple (specifically as it's in template php); gives me immediate visions of a wordpress template - and that's more than enough to scare me off! <lol>

regards,

nathan

--- End Message ---
--- Begin Message ---
I've had a lot of success with Savant3: www.phpsavant.com becuase it's
pretty featureful yet fast(er than the alternatives I tested).

On Sat, May 23, 2009 at 7:01 PM, Nathan Rixham <[email protected]> wrote:

> LinuxManMikeC wrote:
>
>> On Sat, May 23, 2009 at 4:21 PM, Nathan Rixham <[email protected]> wrote:
>>
>>> Hi All,
>>>
>>> Just a quick one, can anybody recommend any decent templating engines
>>> other
>>> than smarty.
>>>
>>> I've got no problem with smarty and it does the job - but if there is
>>> something newer and lighter out there that I'm missing then I'd be a fool
>>> not to at least consider it!
>>>
>>> can't be part of a framework, (or if it is easily extracted with no
>>> framework dependencies), and not xslt (love xslt, but not many designers
>>> do!).
>>>
>>> many regards,
>>>
>>> Nathan
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>> I was recently researching template engines for a small in-house
>> project, with a bias toward simple and lightweight.  I found this
>> interesting article in my search.  I think its worth considering if
>> you don't need all the bells and whistles of the big template engines.
>>  Simple and elegant.
>> http://www.massassi.com/php/articles/template_engines/
>>
>
> cheers, it certainly is simple and elegant - however a bit too simple
> (specifically as it's in template php); gives me immediate visions of a
> wordpress template - and that's more than enough to scare me off! <lol>
>
> regards,
>
> nathan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sat, May 23, 2009 at 10:52:56AM -0400, tedd wrote:

> At 9:08 AM -0400 5/23/09, Robert Cummings wrote:
>> Ya know... the people over at HTML standards design cold have saved the
>> world a large number of headaches by just adding a new attribute to
>> tables:
>>
>>     <table type="layout">
>>
>> Then everyone layout table out there would have been valid by the simple
>> addition of this attribue, backward compatible with older browsers,
>> understandable by future screen readers, and much less hassle in
>> general. But, I guess they were lacking some insight there. Instead we
>> got a CSS spec to support table layouts that depended on the asshats
>> over at Microsoft adding support, required all browsers at the time be
>> upgraded, and today is pretty much useless in a global perspective. I'm
>> all for standards, we could have even overlapped this system with CSS
>> support so that when the browser support ultimately came, the switch
>> would be simple. But no, simplicity would have been far too easy for
>> everyone to swallow.
>
> Rob:
>
> Ain't that the truth.
>
> On one side, people who had very little programming skills took
> advantage of the HTML language through WYSIWYG editors and created
> something that solved their needs.
>
> On the other side, the same people who didn't foresee the problem
> when they created the language ignores the obvious need for layout
> and then further complicates the issue by redefining tables and
> requiring a css solution. They could have easily sought a simple
> solution such as what you suggested.
>
> I often think there should be a "grid" of some sort to allow people
> to construct a layout without having to consider the more problematic
> css positioning and float rules. What better solves that layout
> problem than a table? Opportunities lost.

I wish someone had thought of a similar thing for databases. From the
beginning, there should have been a spreadsheet-like interface for
databases. This could have saved endless trouble, since for lack of
this, people store database information in spreadsheets. And then wonder
why they can't do this or that with it. Argh.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
Paul M Foster wrote:


I wish someone had thought of a similar thing for databases. From the
beginning, there should have been a spreadsheet-like interface for
databases. This could have saved endless trouble, since for lack of
this, people store database information in spreadsheets. And then wonder
why they can't do this or that with it. Argh.

If I'm not mistaken, Filemaker Pro on Apple was that way back in the OS 7.6 days.
--- End Message ---
--- Begin Message ---
On Sat, 2009-05-23 at 22:23 -0700, Michael A. Peters wrote:
> Paul M Foster wrote:
> 
> > 
> > I wish someone had thought of a similar thing for databases. From the
> > beginning, there should have been a spreadsheet-like interface for
> > databases. This could have saved endless trouble, since for lack of
> > this, people store database information in spreadsheets. And then wonder
> > why they can't do this or that with it. Argh.
> 
> If I'm not mistaken, Filemaker Pro on Apple was that way back in the OS 
> 7.6 days.
> 
The only thing worse than using spreadsheets for databases is using word
processors for screenshots!


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Hi,

   Whenever I am using date('r') function It shows time in GMT instead of
local time set on my machine. Do I need to configure the time separately. I
am using WAMP server locally.

Thanks,
         Sumit

--- End Message ---
--- Begin Message ---
Sumit Sharma wrote:
Hi,

   Whenever I am using date('r') function It shows time in GMT instead of
local time set on my machine. Do I need to configure the time separately. I
am using WAMP server locally.

Thanks,
         Sumit


Not sure about windows - but

putenv("TZ=America/Los_Angeles");

in your script should work (change the timezone to whatever you want locally).

You should be able to set the TZ variable globally in your php.ini file.

--- End Message ---
--- Begin Message ---
is this a bad practice?
i want to create a database class, with a particular definition when
server supports PDO and a different definition if  the server does not

comments please.
Kranthi.

--- End Message ---
--- Begin Message ---
As long as you design it with a consistent interface I don't see a
problem.  The whole point of creating abstractions like this is so
when you're writing the rest of your code you don't have to think
about the gritty details behind the scenes (like PDO or non-PDO).  If
you design the class so that the programmer using it just has to think
"I'm using a 'data source', and this is how I use it", then you did it
right.

Also, keep in mind that its not about what we think about your idea,
but what works for you in practice.  Your idea is sound.  Now when it
comes to implementing it, you could get it completely wrong.  Then you
need to care what we think.  Good luck.

Mike

On Sat, May 23, 2009 at 11:46 PM, kranthi <[email protected]> wrote:
> is this a bad practice?
> i want to create a database class, with a particular definition when
> server supports PDO and a different definition if  the server does not
>
> comments please.
> Kranthi.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
thanks for the comments,

what i m planning to do is....

function _autoload($class) {
 if($class == 'Database') {
   if(class_exis('PDO') {
    include_once('Database_PDO.php');
   } else {
    include_once('Database.php');
 }
}
where in  Database_PDO.php contains

class Database extends PDO {
}

Database.php contains

class Database {
}

--- End Message ---
--- Begin Message ---
kranthi wrote:
thanks for the comments,

what i m planning to do is....

function _autoload($class) {
 if($class == 'Database') {
   if(class_exis('PDO') {
    include_once('Database_PDO.php');
   } else {
    include_once('Database.php');
 }
}
where in  Database_PDO.php contains

class Database extends PDO {
}

Database.php contains

class Database {
}

appears to me it should be:

abstract class Database {
class PDODatabase extends Database {
class MysqlDatabase extends Database {
...etc

because if you don't have PDO how can you extend it...? ;)

then

class Persistence {

  private static $database;

  public function select( $sql )
  {
     self::getDatabase()->query( $sql );
  }

  public static function getDatabase()
  {
    if( !(self::$database instanceof Database) ) {
        if( class_exists( 'PDODatabase' ) ) {
          self::$database = new PDODatabase();
        } elseif( function_exists('mysql_query') ) {
          self::$database = new MysqlDatabase();
        }
    }
    return self::$database;
  }

}

or suchlike

one thing you will need to consider is getting database connection settings in there for instantiation; in which case injecting a configured instance of the required database handler in to the persistence layer may be more suitable.
--- End Message ---
--- Begin Message ---
Hi list,

I'm looking for a nice, user (i.e. me) friendly general-purpose IDE,
where most of my work will be done in PHP.

I'm considering using Dreamweaver CS4 as my IDE, where I will disable
most of the WYSIWYG elements and use all of the other features that I
need/want (contextual syntax coloring and project management).

But before I try that, are there any suggestions from all you experts out there?

Thanks,
 - Casey

--- End Message ---
--- Begin Message ---
one of the most frequently asked question...

assuming your platform is windows..

my recommendation is a combo of phpDesigner and CS4.

phpDesigner is best IDE i hav seen till date (for PHP), but its not
suited do ny CSS/HTML coding

Notepad++ will be helpful to debug HTML errors(like closing tags and stuff)

--- End Message ---
--- Begin Message ---
Casey wrote:
Hi list,

I'm looking for a nice, user (i.e. me) friendly general-purpose IDE,
where most of my work will be done in PHP.

I'm considering using Dreamweaver CS4 as my IDE, where I will disable
most of the WYSIWYG elements and use all of the other features that I
need/want (contextual syntax coloring and project management).

But before I try that, are there any suggestions from all you experts out there?

Eclipse + PHPEclipse and you don't even have to worry about the windows/linux question. Runs transparently on both ( apart from the path differences ) and you can handle all of the extra things such as html, css, phpdoc, xml ... without moving outside the IDE.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
Lester Caine wrote:
Casey wrote:
Hi list,

I'm looking for a nice, user (i.e. me) friendly general-purpose IDE,
where most of my work will be done in PHP.

I'm considering using Dreamweaver CS4 as my IDE, where I will disable
most of the WYSIWYG elements and use all of the other features that I
need/want (contextual syntax coloring and project management).

But before I try that, are there any suggestions from all you experts out there?

Eclipse + PHPEclipse and you don't even have to worry about the windows/linux question. Runs transparently on both ( apart from the path differences ) and you can handle all of the extra things such as html, css, phpdoc, xml ... without moving outside the IDE.


second third and forth that - eclipse pdt is the way to go, has a feature set like no other, and you can run your php live inside the IDE with step throughs and break points etc. Also the code templates, source formatting, jump to variable, class, method and code completion really really really makes a huge difference (not to mention it shows you all syntax problems)

dw is decent if you do more html and need the design view - but if your using it purely for the code view then there is no comparison.

alternatively zend studio and netbeans php ide are both strong contenders and feature-full like eclipse pdt.

eclipse though has a much strong community behind it, is pretty much standard for other languages like flex, java, c and has more perspectives and views than you can need.

for a quick start, here's a precompiled pack i made
http://wiki.voom.me/wiki/Eclipse-PDT2-Perfect-Setup

which is PDT 2 and:
* Zend Executable Debugger Eclipse Plug-in (everything you need to run and debug php scripts within eclipse) * Subversive SVN Connector, Team Provider and SVNKit (everything you need to fully integrate eclipse with SVN) * Mylyn with Bugzilla and Trac Connectors (mylyn is a task manager which integrates in with most bug trackers) * Java Development Tools 3.4.1 - contains support for apache ant (needed for automated building in eclipse, indeed anything useful)
    * all the required dependencies for the above.

regards!

--- End Message ---
--- Begin Message ---
Hi All,

A recent post just reminded me of something I did a while ago that may be of use to many of you (and its sitting doing nothing), it's a kind of how to for getting a full development environment up and running simply.


Eclipse PDT 2 + extras
http://wiki.voom.me/wiki/Eclipse-PDT2-Perfect-Setup

Subversion auto props
http://wiki.voom.me/wiki/SubversionAutoProps

PHP Tools - XDebug, PHPDocumentor, PHP Code Sniffer, PHPUnit
http://wiki.voom.me/wiki/VoomWorkingEnvironment#SettingUpTheLocalPHPPEAREnvironment

(Ubuntu Specific - Continuous Integration)
XDebug, PHPDocumentor, PHP Code Sniffer, PHPUnit, Cruise Control, phpUnderControl
http://nathan.voom.me/wiki/PHP-ContinuousIntegration

All that should save a few days of work setting up configuring and exploring.

Servers & Bandwidth courtesy of Dan Brown @ Parasane - thanks mate.
http://parasane.net/

Hope it helps somebody!

regards,

nathan

--- End Message ---

Reply via email to