php-general Digest 3 Aug 2009 08:01:20 -0000 Issue 6264
Topics (messages 296183 through 296190):
Re: PHP programming strategy
296183 by: Eddie Drapkin
PHPGitAdmin Project Brainstorm
296184 by: Daniel Kolbo
Re: Problem: Writing into Files?
296185 by: Richard Heyes
newbie: how to return one iteration *per unique date (DAY!)* in a timestamp
column?
296186 by: Govinda
how to pass variable argument list in a childconstructor to parent constructor,
ideas wanted
296187 by: Ralph Deffke
296188 by: Jonathan Tapicer
Re: Script to Compare Database Structures
296189 by: Mattias Thorslund
Radio buttons problem
296190 by: leledumbo
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Sun, Aug 2, 2009 at 2:24 PM, Larry Garfield<la...@garfieldtech.com> wrote:
> On Saturday 01 August 2009 11:01:11 pm Eddie Drapkin wrote:
>> > I actually benchmarked that once. I had a reasonably large PHP file that
>> > was, in fact, over 50% docblocks. That's not even counting inline
>> > comments. While trying to find things to optimize, removing about 800
>> > lines worth of comments (all of the docblocks) did, in fact, produce a
>> > noticeable performance difference. It was only barely noticeable, but it
>> > just barely registered as more than random sampling jitter. I actually
>> > concluded that if cutting the file *in half* was only just barely
>> > noticeable, then it really wasn't worth the effort.
>>
>> Yeah but what happens if you run the script through the tokenizer and
>> strip ALL comments, unnecessary whitespace, newline characters, etc.
>> out?
>
> Honestly? I think you'll save more CPU time by eliminating one SQL query.
> Most files are not 60% comments. In a file that is only about 20% comments, I
> doubt you could even measure the difference. There are far far far more
> useful
> ways to optimize your code.
>
> (Note that this is different for CSS or Javascript, where compressors like
> that
> are commonplace because you have to transfer the entire file over the network
> repeatedly, which is a few orders of magnitude slower than system memory.
> Compressors and aggregators there make sense. PHP code never leaves the
> server, so those benefits don't exist.)
>
> --
> Larry Garfield
> la...@garfieldtech.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Seems the sarcasm / attempted comedy was lost in translation!
--Eddie
--- End Message ---
--- Begin Message ---
Hello,
I had a thought today while walking...why do all ideas come while
walking under the sun rather than slouching in front of the LCD's glow?
Wouldn't it be cool to develop an application that allowed one to manage
Git via PHP? I'm thinking, sorta like how the PHPMyAdmin project helps
people manage MySQL via PHP.
The reach for PHPGitAdmin would prolly not be as great as it is for
PHPMyAdmin, b/c most hosting services do not let one run git (executing
shell commands), i assume.
I'm still new to Git and Subversion, after a few days of research I
think I'm more inclined towards Git. I am not exactly sure how the
PHPGitAdmin project would work, but I'm thinking aloud right now.
Maybe there is such a feature already available. I guess eclipse and
the git plug-in effectively accomplish a similar task, but this requires
people to have the eclipse framework rather than a browser and the i-net
(which everyone hopefully has).
What do you all think about this project?
Thanks,
dK
`
--- End Message ---
--- Begin Message ---
> I don't quite know how I can write a bite into a file. I also looked into a
> manual and couldn't find a mention of FLock-ing in the explaination for
> FOpen parameters.
Ok, from memory:
<?php
fwrite(fopen('/tmp/counter', 'a'), '1');
?>
The 1 could be any single byte character I guess.
--
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 25th July)
Lots of PHP and Javascript code - http://www.phpguru.org
--- End Message ---
--- Begin Message ---
Hi all
I posted this on the PHP-db list, but it is sunday.. and with so
little traffic today, perhaps no one will mind if I post this here
too? (with hoped I'll get a quicker pointer?).
I'm translating some code from another server-side language into PHP,
and I need something that 'summarizes' results found from a MySQL
SELECT. I.e. -
$foundTrackingRows=mysql_query("SELECT...
while ($TrackingRow = mysql_fetch_object($foundTrackingRows)) {...
..such that the while loop only loops *ONCE per unique _date_ found
(regardless of the hour/min./sec.)* in my column which is of type
TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
PRIMARY KEY
For example, if I have column values like these:
2009-08-01 07:01:00
2009-07-30 18:16:37
2009-07-30 17:49:06
2009-07-27 17:35:52
2009-07-27 17:24:21
2009-07-27 17:23:03
..then my while { loop would only fire 3 times.
I do my RTFM; can someone just give me a good point in the right
direction.
Thanks!
------------
John Butler/(Govinda)
govinda.webdnat...@gmail.com
--- End Message ---
--- Begin Message ---
problem:
__ construct( $something ... variable argument list ){
parent::__construct( ??? );
}
I tried with func_get_args, but the problem is that it gives an indexed
array back.
lets say the argument list is mixed like this:
( "string", "string", array)
func_get_args will give this
[0] => "string"
[1] => "string"
[2] => array
the parent constructor works also with the func:_get_args function in ordfer
to handle variable argument lists
if u pass the array from func_get_args the parent constructor will reveive
after his func_get_args the following
array( [0] => array( [0] => "string" [1] =>"string" [2] => array( ....)
ok no problem so far. I thought just strip the key column of the array with
a function like this
function stripFirstColumn( $_fromThisArray ){
$b = "";
$_b = array();
foreach( $_fromThisArray as $value){
if( !is_array($value) ){
if( empty( $b )){
$b = $value;
// $_b[$b]="";
} else {
$_b[$b]=$value;
$b = "";
}
} else {
array_push($_b, $value); or $_b[] = $value;
}
}
return $_b;
}
BUT this results in an arry like this
array( "string", "string", [0] => array( ...))
HOWEVER u can create a propper array for this purpose by writing this :
$_a = array( "string", "string", Array( "string" => "string",
"string"=>"string"));
but there is no way to create the same construction by code unless I use the
eval() function what limits me to string objects only.
im really a senior coder (since 1982) but this gives me a headace. what do u
think?
--- End Message ---
--- Begin Message ---
I don't understand completely your problem, but think that something
like this may help you:
<?php
class A
{
function __construct()
{
var_dump(func_get_args());
}
}
class B extends A
{
function __construct()
{
$args = func_get_args();
call_user_func_array(array(parent, '__construct'), $args);
}
}
$a = new B(1, 2, 3);
?>
This will output:
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
As expected.
The key is using call_user_func_array in combination with
func_get_args to call the parent constructor without knowing the
number of parameters.
Let me know if that helps.
Jonathan
On Sun, Aug 2, 2009 at 10:40 PM, Ralph Deffke<ralph_def...@yahoo.de> wrote:
> problem:
>
> __ construct( $something ... variable argument list ){
> parent::__construct( ??? );
> }
>
> I tried with func_get_args, but the problem is that it gives an indexed
> array back.
>
> lets say the argument list is mixed like this:
> ( "string", "string", array)
>
> func_get_args will give this
> [0] => "string"
> [1] => "string"
> [2] => array
>
> the parent constructor works also with the func:_get_args function in ordfer
> to handle variable argument lists
>
> if u pass the array from func_get_args the parent constructor will reveive
> after his func_get_args the following
>
> array( [0] => array( [0] => "string" [1] =>"string" [2] => array( ....)
>
> ok no problem so far. I thought just strip the key column of the array with
> a function like this
>
> function stripFirstColumn( $_fromThisArray ){
> $b = "";
> $_b = array();
> foreach( $_fromThisArray as $value){
> if( !is_array($value) ){
> if( empty( $b )){
> $b = $value;
> // $_b[$b]="";
> } else {
> $_b[$b]=$value;
> $b = "";
> }
> } else {
> array_push($_b, $value); or $_b[] = $value;
> }
> }
> return $_b;
> }
>
> BUT this results in an arry like this
>
> array( "string", "string", [0] => array( ...))
>
> HOWEVER u can create a propper array for this purpose by writing this :
>
> $_a = array( "string", "string", Array( "string" => "string",
> "string"=>"string"));
>
> but there is no way to create the same construction by code unless I use the
> eval() function what limits me to string objects only.
>
> im really a senior coder (since 1982) but this gives me a headace. what do u
> think?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Look into the Reverse module of PEAR MDB2.
http://pear.php.net/manual/en/package.database.mdb2.intro-reverse-module.php
Cheers,
Mattias
Matt Neimeyer wrote:
I know I CAN hack something together but I hate to reinvent the wheel.
I want to be able to compare the structure of two different clients
databases that might be on different servers that are firewalled away
from each other. Given the two structures it will list all the SQL
commands needed to make the database structure the same.
In a perfect world on one side you would pull up a PHP page that does
a "generate structure" which would create a downloadable file which
you could then upload to the other system which would then give a
listing of the SQL commands needed to make the local structure match
the uploaded structure.
Thanks in advance...
Matt
--- End Message ---
--- Begin Message ---
I'm creating a form with variable number of entries (user controlled) where
each entry consists of some input fields. For most input types, appending []
to their names is enough to allow me processing each entry. So, for
instance, if there are 3 entries with field name[] and email[], they can be
accessed as:
name = Array(
0 => 'name1',
1 => 'name2',
2 => 'name3'
)
email = Array(
0 => 'email1',
1 => 'email2',
2 => 'email3'
)
However, this isn't the case for radio buttons. Let's see a common usage:
sex determinition. Using sex[] will make the one in an entry to behave
dependently to another. This is due to the radio button behavior to group
choices based on name.
How can I make a radio button in one entry to behave independently from the
one in another so that it can be accessed as name and email above?
--
View this message in context:
http://www.nabble.com/Radio-buttons-problem-tp24786766p24786766.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---