php-general Digest 28 Jan 2009 14:59:37 -0000 Issue 5927
Topics (messages 287258 through 287268):
Re: Hidden costs of PHP arrays?
287258 by: Nathan Rixham
Installation of php-5.2.8-win32-installer.msi
287259 by: Jerry Foote
287260 by: Chris
287262 by: Chris
287264 by: Ashley Sheridan
Re: Programming general question
287261 by: Paul M Foster
287266 by: Ondrej Kulaty
Re: Global Changes With Loop To Allow Nulls In A Table...
287263 by: revDAVE
287268 by: Andrew Ballard
unlink file rights problem
287265 by: Merlin Morgenstern
287267 by: Shawn McKenzie
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 ---
Robert Cummings wrote:
On Wed, 2009-01-28 at 10:38 +1100, Clancy wrote:
PHP arrays permit extremely concise programming; for example if I have all my
contacts in
an array $contacts, I can write:
$my_phone_no = $contacts['clancy']['phone'];
However it is clear that there must be a lot going on behind the scenes to
achieve this
simple result, as it requires some sort of search procedure.
Is it possible to give any indication of the overheads and memory costs that
are involved
in such a statement, and of how well the search procedure is implemented?
Also what the relative virtues of defining the same set of fields for every
contact, as
against either defining only the fields which actually hold values, as in the
following
examples?
a:
$contacts['clancy']['home_address'] = 'jkjkjk';
$contacts['clancy']['home_phone'] = 0123 4567;
$contacts['clancy'][' office_address''] = '';
$contacts['clancy']['office_phone'] = '';
$contacts['joe']['home_address'] = '';
$contacts['joe']['home_phone'] = '';
$contacts['joe']['office_address'] = 'jsfvkl';
$contacts['joe']['office_phone'] = 'jsfvkl';
b;
$contacts['clancy']['home_phone'] = 0123 4567;
$contacts['clancy']['home_address'] = 'jkjkjk';
$contacts['joe']['office_address'] = 'jsfvkl';
$contacts['joe']['office_phone'] = 'jsfvkl';
And is there any advantage in always assigning the keys in the same order?
Lookup is O( lg n ). Since your examples above are nested 2 levels deep
then it's actually 2 * O( lg n ) which is O( lg n ). But really, the
variable itself, $contacts is probably also looked up and it is also
O( lg n ) and of course 3 * O( lg n ) is still O( lg n ). Moving
along... for arbitrary depth paths, you'd be talking O( m lg n ) but for
realistic cases you'll not get deep enough for that to matter much.
Either way, if you are looping over an array and always accessing X
levels deep, you might want to create a temporary variable that is level
X - 1 (unless that's not a possible option).
Cheers,
Rob.
rob; go apply for a job at yahoo - that's one of there interview
questions for new developers [describe o notation]
<is impressed - v nice answer>
--- End Message ---
--- Begin Message ---
Tried to install PHP using this installer and about 2/3 of the way through
the installation I get an error message:
I am trying to install the IIS ISAPI module and MySQL to the hard drive
under c:\Program Files\PHP on an XP Professional SP2 machine.
Any help on this problem?
Jerry Foote
ScopeCraft, Inc.
4175 E. Red Cliffs Dr.
Kanab, UT 84741
435-899-1255
[email protected]
--- End Message ---
--- Begin Message ---
Jerry Foote wrote:
Tried to install PHP using this installer and about 2/3 of the way
through the installation I get an error message:
I am trying to install the IIS ISAPI module and MySQL to the hard drive
under c:\Program Files\PHP on an XP Professional SP2 machine.
The mailing list doesn't accept attachments so you'll have to write out
the error by hand.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Always cc the mailing list so others can offer suggestions/advice and so
it will also show up in the archives later on.
Jerry Foote wrote:
The error message is:
"There is a problem with this Windows Installer package. A script
required for this install to complete could not be run. Contact your
support personnel or package vendor."
Anything in the windows event log?
If not I'd probably ask either on the windows mailing list or the
install list. You can sign up for either/or here:
http://www.php.net/mailing-lists.php
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On Wed, 2009-01-28 at 12:52 +1100, Chris wrote:
> Jerry Foote wrote:
> > Tried to install PHP using this installer and about 2/3 of the way
> > through the installation I get an error message:
> >
> >
> >
> >
> >
> > I am trying to install the IIS ISAPI module and MySQL to the hard drive
> > under c:\Program Files\PHP on an XP Professional SP2 machine.
>
> The mailing list doesn't accept attachments so you'll have to write out
> the error by hand.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
Or link to an online image of the error.
Ash
www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Tue, Jan 27, 2009 at 05:18:35PM -0600, Terion Miller wrote:
> I googled this and didn't find an answer ....
> my question is how do you know when to use an object or array
>
> would an object just be 1 instance, and array is several things together ( I
> know infantile coder language I use..but I'm a baby still in this)
>
> Can someone explain objects and arrays in plain speak for me?
An array is like in math, except that an array in PHP stores anything
you like. It's just a bunch of them together.
An object can also store a bunch of different things, but it also has
"methods", which are really just functions. An array won't actually *do*
anything; you have to do things *to* it. An object can actually do stuff
at your direction. Like:
$kitchen->make_coffee('cream', 'sugar');
The object here is $kitchen, and you've told it to use its make_coffee()
method, which does something or another. You can also make those
"methods" private so that code outside the object can't "see" them.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
Depends on what for you want to use that. Array is simple data structure, it
holds data, like variable, but objects has methods and properties, it acts
as someting which can do some sort of task and you access it via it's
interface (you call it's methods). You can use array for example to hold
result from database and than iterate it with for or foreach cycle. On the
other hand, object can be used for exaplme to send mail, you put into it
text body, mail adresses and so on and then call it's method send() which
causes mail to be send. The process of transforming data, generating headers
etc is completely done by the object and it's internal methods, you access
it only via it's well defined interface (it's methods you can call). Objects
are mainly used in OOP programming, where they cooperate together. Good way
to learn OOP is to learn something about design patterns...
--
"Terion Miller" <[email protected]> píse v diskusním príspevku
news:[email protected]...
>I googled this and didn't find an answer ....
> my question is how do you know when to use an object or array
>
> would an object just be 1 instance, and array is several things together
> ( I
> know infantile coder language I use..but I'm a baby still in this)
>
> Can someone explain objects and arrays in plain speak for me?
> Thanks
> Happy Coding
>
--- End Message ---
--- Begin Message ---
Thanks so much for everyone's help!
I fooled with this and it was cool...
In the mysql client, do a SHOW CREATE TABLE tableName\G
And ultimately got it working with:
---------
The MySQL syntax to alter a column is:
ALTER TABLE `table` MODIFY `column` BIGINT NOT NULL;
[ http://dev.mysql.com/doc/refman/5.1/en/alter-table.html ]
The sql statement
SHOW COLUMNSFROM `table`;
[ http://dev.mysql.com/doc/refman/5.1/en/show-columns.html ]
Thanks again!!!!
--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]
--- End Message ---
--- Begin Message ---
On Tue, Jan 27, 2009 at 5:24 PM, Boyd, Todd M. <[email protected]> wrote:
>> -----Original Message-----
>> From: Chris [mailto:[email protected]]
>> Sent: Tuesday, January 27, 2009 4:04 PM
>> To: Boyd, Todd M.
>> Cc: [email protected]
>> Subject: Re: [PHP] Global Changes With Loop To Allow Nulls In A
>> Table...
>>
>>
>> >> The other responses should get you started if this is something you
>> >> really want to do. However, I'll play devil's advocate here and just
>> >> raise the question why you would want to make this change in the
>> first
>> >> place. I'm not quite as anti-NULL as a lot of arguments I've read
>> >> against them, but I tend to agree that the number of columns that
>> >> accept NULL values should be kept as small as possible. Even if you
>> >> decide that you need to allow NULL values in some cases, IMHO I
>> >> wouldn't write a script that ran through my entire database and
>> opened
>> >> every column in every table to accept.
>> >
>> > I just thought I'd throw this out there...
>> >
>> > A lot of people who post questions on this list are programming their
>> algorithms and structuring their applications in a certain way because
>> that's what the client wants, or that's what their boss told them to
>> do. Yes, accepting NULL values in a database is frowned upon (unless
>> the table is a transaction table)... but I doubt his boss or his client
>> cares in the least.
>>
>> I don't understand what you mean about a "transaction table" - you
>> should only use nulls if you understand what they do and why you'd need
>> them in that particular case. I'd ask why and find specifically what
>> they want/why they suggested it and make sure they understand the
>> repercussions.
>
> A transaction table -- a table that is used to house the state of a
> transaction. If the transaction is incomplete, some of its values will be
> NULL. This is, of course, only one method for employing a transaction system.
> There exist others that use many disparate tables for separate steps in the
> transaction, but I've seen several that use one table with NULL columns for
> steps that haven't yet been processed.
>
>
> // Todd
>
Even so - I would think it undesirable (and dangerous) for EVERY
column (including primary/foreign keys) in EVERY table to allow NULL
values. Granted, I don't know the nature of the project here, nor the
problem being addressed. I just wanted to raise a flag noting that
this MAY not be a great idea in the event a self-described "newbie"
hadn't considered the potential pitfalls he could be introducing.
Andrew
--- End Message ---
--- Begin Message ---
Hi there,
I am trying to unlink a file which is inside a folder that is not
writable to phps user "www". Of course this failes, but I need to find a
solution for it.
Backgroud is following:
I have pure-ftpd installed where user directories get created by
pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does
only create the homedirectory folder in 750 mod.
My PHP-Script scans this directories every x minutes and processes those
files. Upon completinon those files should get deleted, but as the dir
is not writable by the user www this failes.
The dir looks like this:
drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/
files inside look like this:
-rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml*
User www which executes php via cron is inside the group "ftpgroup".
Any ideas? I am kind of lost with this one. Thank you for any help!
Best regards, Merlin
--- End Message ---
--- Begin Message ---
Merlin Morgenstern wrote:
> Hi there,
>
> I am trying to unlink a file which is inside a folder that is not
> writable to phps user "www". Of course this failes, but I need to find a
> solution for it.
>
> Backgroud is following:
> I have pure-ftpd installed where user directories get created by
> pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does
> only create the homedirectory folder in 750 mod.
> My PHP-Script scans this directories every x minutes and processes those
> files. Upon completinon those files should get deleted, but as the dir
> is not writable by the user www this failes.
>
> The dir looks like this:
> drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/
>
> files inside look like this:
> -rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml*
>
> User www which executes php via cron is inside the group "ftpgroup".
>
> Any ideas? I am kind of lost with this one. Thank you for any help!
>
> Best regards, Merlin
Why not run the cron as root, or ftpuser?
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---