php-general Digest 14 Jul 2011 10:08:19 -0000 Issue 7401
Topics (messages 314042 through 314063):
What is a label?
314042 by: Tim Streater
314043 by: Micky Hulse
314044 by: Tim Streater
Most popular word sorting
314045 by: Ron Piggott
314047 by: Stuart Dallas
Your language sucks because...
314046 by: Daevid Vincent
314048 by: Micky Hulse
314049 by: Lester Caine
314050 by: Florian Müller
314052 by: Alex Nikitin
314061 by: Tim Streater
Re: PHP control structure
314051 by: Tamara Temple
314054 by: Negin Nickparsa
Report generation as pdf and csv in php application for huge record set
314053 by: Midhun Girish
314057 by: George Langley
314058 by: Midhun Girish
314059 by: George Langley
314062 by: George Langley
IF stream lining
314055 by: Ron Piggott
314056 by: Alex Nikitin
314060 by: Tamara Temple
Re: Serveside Printing w/ PHP
314063 by: Richard Quadling
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 ---
Looking over the definition of a function today I see:
Function names follow the same rules as other labels in PHP.
but I can't find the definition of a label anywhere. I can't see it listed in
the contents - have I overlooked it? If not, how can I request the the doccy be
updated?
Tim Streater
Bedford House
Kake St
Waltham CT4 5RZ
01227 700322
--- End Message ---
--- Begin Message ---
They must mean labels as in "general naming convention rules for
programming"... Like not naming a variable/function "label" with a number at
the front.
Here's a page about variables:
http://www.php.net/manual/en/language.variables.basics.php
Variable names follow the same rules as other labels in PHP. A valid
variable name starts with a letter or underscore, followed by any
number of letters, numbers, or underscores. As a regular expression,
it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
But I agree though, it would be nice if "label" was defined somewhere
in the docs.
--- End Message ---
--- Begin Message ---
On 13 Jul 2011 at 22:39, Micky Hulse <[email protected]> wrote:
> They must mean labels as in "general naming convention rules for
> programming"... Like not naming a variable/function "label" with a number at
> the front.
>
> Here's a page about variables:
>
> http://www.php.net/manual/en/language.variables.basics.php
>
> Variable names follow the same rules as other labels in PHP. A valid
> variable name starts with a letter or underscore, followed by any
> number of letters, numbers, or underscores. As a regular expression,
> it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
Except that variables are case-sensitive whereas function names are not. And if
there's going to be a formal or "programmatic" definition, then I think I'd
prefer BNF to a regexp.
--
Cheers -- Tim
--- End Message ---
--- Begin Message ---
Is it possible in PHP to sort an array by most frequently occurring word /
phrase, 2nd most frequently occurring, third, etc.
An example array is:
Array ( [1] => Parable [2] => Mustard [3] => Seed [4] => Parable [5] => Good
[6] => Samaritan [7] => Parable [8] => Workers [9] => Vineyard [10] => Parable
[11] => Lost [12] => Sheep [13] => Parable [14] => Lost [15] => Coin [16] =>
Parable [17] => Prodigal [18] => Parable [19] => Sower [20] => Parable [21] =>
Weeds [22] => Parable [23] => Hidden [24] => Treasure [25] => Parable [26] =>
Parable [27] => Wedding [28] => Banquet [29] => Parable [30] => Virgins [31] =>
Parable [32] => Bags [33] => Gold [34] => Parable [35] => Yeast )
The most popular word is “Parable”. I would like it to be the first result.
Then the second most popular word is “Lost”.
Then all the remaining words are only used once.
Ron
The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info
--- End Message ---
--- Begin Message ---
On Wednesday, 13 July 2011 at 23:30, Ron Piggott wrote:
> Is it possible in PHP to sort an array by most frequently occurring word /
> phrase, 2nd most frequently occurring, third, etc.
>
> An example array is:
>
> Array ( [1] => Parable [2] => Mustard [3] => Seed [4] => Parable [5] => Good
> [6] => Samaritan [7] => Parable [8] => Workers [9] => Vineyard [10] =>
> Parable [11] => Lost [12] => Sheep [13] => Parable [14] => Lost [15] => Coin
> [16] => Parable [17] => Prodigal [18] => Parable [19] => Sower [20] =>
> Parable [21] => Weeds [22] => Parable [23] => Hidden [24] => Treasure [25] =>
> Parable [26] => Parable [27] => Wedding [28] => Banquet [29] => Parable [30]
> => Virgins [31] => Parable [32] => Bags [33] => Gold [34] => Parable [35] =>
> Yeast )
>
> The most popular word is “Parable”. I would like it to be the first result.
> Then the second most popular word is “Lost”.
> Then all the remaining words are only used once.
If I'd have spent two minutes reading the array section of the manual first I'd
have found this... http://php.net/array_count_values
But I didn't, so I wrote this... https://gist.github.com/1081541
Meh!
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
(at the risk of starting another $h!t storm like the last time)
http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because:
;-)
--- End Message ---
--- Begin Message ---
Under the CSS section:
No way to modularize or programmatically generate lengths. Can't say:
{ width:50% - 2px; }
That's so true!!!!!! I wish I could do the above...
Oh, and why is the PHP section so damned long?!?
Good read, thanks. :)
--- End Message ---
--- Begin Message ---
Daevid Vincent wrote:
(at the risk of starting another $h!t storm like the last time)
http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because:
Perhaps when they get around to checking the facts ... most of the content will
be deleted? A number of the -ve's I'd personally flag as +ve's and complain if
anybody changed them ...
Generally I'd say the whole page simply sucks :)
--
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 ---
Well ..... do you have any hobbies or such?
I think if you like it to complain about languages sucking and so on, please do
NOT spam this mailing list with this really USELESS content.
There are some people out there who are using these languages for some good
reasons, and I guess they give a f*ck on somebody telling that all languages
suxx.
Please ask somebody for a hobby.
> Date: Thu, 14 Jul 2011 01:59:27 +0100
> From: [email protected]
> To: [email protected]
> Subject: Re: [PHP] Your language sucks because...
>
> Daevid Vincent wrote:
> > (at the risk of starting another $h!t storm like the last time)
> >
> > http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because:
>
> Perhaps when they get around to checking the facts ... most of the content
> will
> be deleted? A number of the -ve's I'd personally flag as +ve's and complain
> if
> anybody changed them ...
> Generally I'd say the whole page simply sucks :)
>
> --
> 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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
I'm actually interested in finding out if there are any languages that don't
suck in any way... I know and have programmed in about 29, i have yet to
find a language that makes 100% sense and i have no complaints about.
However i still choose PHP over many, many other languages and i implement
php apis because its such an easy to learn, versatile, and as advanced as
you want to make it language; i mean i've written vfat in php for fun, as
well as self-documenting or self-correcting libraries with reflection,
advanced sorting algorithms (like a pimped radix sort that did positive, and
negative integers and floats), and yet teach people how to write stuff in
php in minutes, people never exposed to programming...
In short, PHP does suck, but so do all languages, so when compared, php
actually doesn't suck anywhere near as much as some other oftenly used
languages.
Anyways, just my $.02
With Regards...
--Alex
On Jul 13, 2011 9:15 PM, "Florian Müller" <[email protected]> wrote:
--- End Message ---
--- Begin Message ---
On 14 Jul 2011 at 01:59, Lester Caine <[email protected]> wrote:
> Daevid Vincent wrote:
>> (at the risk of starting another $h!t storm like the last time)
>>
>> http://wiki.theory.org/YourLanguageSucks#PHP_sucks_because:
>
> Perhaps when they get around to checking the facts ... most of the content
> will
> be deleted? A number of the -ve's I'd personally flag as +ve's and complain if
> anybody changed them ...
> Generally I'd say the whole page simply sucks :)
Particularly as it's written by a fathead who thinks that "lose" is spelt
"loose".
--
Cheers -- Tim
--- End Message ---
--- Begin Message ---
On Jul 12, 2011, at 10:11 PM, Chris Stinemetz wrote:
Hey all,
I would like to add an if statement to the following function so that
the value 1 is assigned "corporate" and the value is 2 assign
"standard" to it. Would you show me an example on adding it to the
below function? If there is a better way to reassign the value please
share.
Thank you,
Chris
public function ShowType()
{
$sql = "SELECT DISTINCT store_type FROM store_list WHERE
id_markets=$_POST[id]";
$res = mysql_query($sql,$this->conn);
$Type = '<option value="0">store type...</option>';
while($row = mysql_fetch_array($res))
{
$Type .= '<option value="' . $row['id_store'] .
'">' .
$row['store_type'] . '</option>';
}
return $Type;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I'm really not at all clear what you want to do here. Where and how
are the values going to be used? Where is it determined something is
"corporate" or "standard"? What do these things mean in the context of
your application?
--- End Message ---
--- Begin Message ---
if the problem is only the assigning it's an example:
in mysql you can have this one:
create table store_list(id_markets int auto_increment,store_type int,primary
key(id_markets));
and for page this one:
<html>
<head>
<title>Store</title>
</head>
<form method="post">
<?php
$connection=Mysql_connect('localhost','admin','123');
Mysql_select_db('net',$connection);
if(array_key_exists('sub',$_POST))
if(isset($_POST['store_type']) )
{
$Type =$_POST['store_type'];
$ID=$_POST['id'];
$sql ="update store_list set store_type=$Type where id_markets=$ID";
$res = mysql_query($sql,$connection);
}
?>
<select name='store_type'>
<option value=0>store type<option>
<option value=1>corporate<option>
<option value=2>standard<option>
</select>
ID:<input type='text' name='id'>
<input type='submit' name='sub' value='update the type'>
</form>
</html>
also I didn't understand your code that you have 'id_store' and 'id_markets'
it's confusing for me
if it wasn't your problem please clarify your question maybe I can help.
--- End Message ---
--- Begin Message ---
Hi all,
I have an erp application developed in php (zend framework actually). There
are many reports which the admin level users can take from the application.
Some reports have more than 600,000 records. The viewing of reports in the
browser is fine as i have paginated the result. But when it comes to
exporting the entire report as pdf and in excel format, im in trouble. I use
fpdf for pdf generation and a custom class for converting result to excel.
Both these fails when the number of records exceeds 500. Now i have
pagianted the report generation and users can download the pdf page wise.
But that is not the exact requirement. Im in need of a tool to generate pdf
and excel(or csv) for large data set. I came across
http://www.htmldoc.org/when i googled for one. Has anyone in the list
has faced a similar problem.
How exactly is report generation possible when the number of records is
extremely huge? Is there a good solution which can be implemented in php?
Please help.
Midhun Girish
--- End Message ---
--- Begin Message ---
On 2011-07-13, at 9:59 PM, Midhun Girish wrote:
>
> I have an erp application developed in php (zend framework actually). There
> are many reports which the admin level users can take from the application.
> Some reports have more than 600,000 records. The viewing of reports in the
> browser is fine as i have paginated the result. But when it comes to
> exporting the entire report as pdf and in excel format, im in trouble. I use
> fpdf for pdf generation and a custom class for converting result to excel.
> Both these fails when the number of records exceeds 500. Now i have
> pagianted the report generation and users can download the pdf page wise.
> But that is not the exact requirement. Im in need of a tool to generate pdf
> and excel(or csv) for large data set. I came across
> http://www.htmldoc.org/when i googled for one. Has anyone in the list
> has faced a similar problem.
> How exactly is report generation possible when the number of records is
> extremely huge? Is there a good solution which can be implemented in php?
> Please help.
-----------------
Hi there. FAQ #16 on:
<http://www.fpdf.org/en/FAQ.php#q16>
has some useful info on handling large files:
16. What's the limit of the file sizes I can generate with FPDF?
There is no particular limit. There are some constraints, however:
- The maximum memory size allocated to PHP scripts is usually 8MB. For very big
documents, especially with images, this limit may be reached (the file being
built into memory). The parameter is configured in the php.ini file.
- The maximum execution time allocated defaults to 30 seconds. This limit can
of course be easily reached. It is configured in php.ini and may be altered
dynamically with set_time_limit().
- Browsers generally have a 5 minute time-out. If you send the PDF directly to
the browser and reach the limit, it will be lost. It is therefore advised for
very big documents to generate them in a file, and to send some data to the
browser from time to time (with a call to flush() to force the output). When
the document is finished, you can send a redirection to it or create a link.
Remark: even if the browser times out, the script may continue to run on the
server.
HTH
George Langley
Multimedia Developer
--- End Message ---
--- Begin Message ---
Hi,
> - Browsers generally have a 5 minute time-out. If you send the PDF directly
> to the browser and reach the limit, it will be lost. It is therefore advised
> for very big documents to generate them in a file, and to send some data to
> the browser from time to time (with a call to flush() to force the output).
> When the document is finished, you can send a redirection to it or create a
> link.
> Remark: even if the browser times out, the script may continue to run on
> the server.
> <http://www.php.net/unsub.php>
>
When it comes to the user end, they wont wait for more than 1 min. So
redirection after generating the report is not possible. But creating link
may be a good idea. How can it be done? I mean shouldn't there be a service
running in the server to process these request after the execution of the
php script is completed? Also shouldn't we post all the report generation
request to a database so that serial processing can be done?
--- End Message ---
--- Begin Message ---
On 2011-07-13, at 11:20 PM, Midhun Girish wrote:
> Hi,
>
>
> - Browsers generally have a 5 minute time-out. If you send the PDF directly
> to the browser and reach the limit, it will be lost. It is therefore advised
> for very big documents to generate them in a file, and to send some data to
> the browser from time to time (with a call to flush() to force the output).
> When the document is finished, you can send a redirection to it or create a
> link.
> Remark: even if the browser times out, the script may continue to run on the
> server.
>
>
> When it comes to the user end, they wont wait for more than 1 min. So
> redirection after generating the report is not possible. But creating link
> may be a good idea. How can it be done? I mean shouldn't there be a service
> running in the server to process these request after the execution of the php
> script is completed? Also shouldn't we post all the report generation request
> to a database so that serial processing can be done?
-----------
We're helping each other here, as I'm facing a similar situation! Read
up on how to store as a file here:
<http://www.sitepoint.com/generate-pdfs-php/>
You should then be able to generate an email notification to send once the file
is complete, with the link to the newly-created file.
George Langley
Multimedia Developer
--- End Message ---
--- Begin Message ---
On 2011-07-14, at 12:50 AM, Midhun Girish wrote:
>
>
> On Thu, Jul 14, 2011 at 11:18 AM, George Langley <[email protected]>
> wrote:
> On 2011-07-13, at 11:20 PM, Midhun Girish wrote:
>
> > Hi,
> >
> >
> > - Browsers generally have a 5 minute time-out. If you send the PDF directly
> > to the browser and reach the limit, it will be lost. It is therefore
> > advised for very big documents to generate them in a file, and to send some
> > data to the browser from time to time (with a call to flush() to force the
> > output). When the document is finished, you can send a redirection to it or
> > create a link.
> > Remark: even if the browser times out, the script may continue to run on
> > the server.
> >
> >
> > When it comes to the user end, they wont wait for more than 1 min. So
> > redirection after generating the report is not possible. But creating link
> > may be a good idea. How can it be done? I mean shouldn't there be a service
> > running in the server to process these request after the execution of the
> > php script is completed? Also shouldn't we post all the report generation
> > request to a database so that serial processing can be done?
> -----------
> We're helping each other here, as I'm facing a similar situation! Read
> up on how to store as a file here:
>
> <http://www.sitepoint.com/generate-pdfs-php/>
>
> You should then be able to generate an email notification to send once the
> file is complete, with the link to the newly-created file.
>
>
> George Langley
> Multimedia Developer
>
>
> Suppose we are using this tool at sever side. We have set up the php page so
> that all request will be saved in a db. And based on the conditions in
> request a pdf CAN be generated by this tool. My question is how will we give
> the trigger for generating this pdf? We cant do it in the php script due to
> the timeout problem. The only solution i can think of is a cron which is
> repeated every 5 min or so which fetches records from the db and generates
> the pdf. But even with a cron we will face the timeout problem. Is there any
> alternative to a cron like a server side service or something?
>
>
> Midhun Girish
------------------
As I understand it, the "server-side" timeout can be increased in the
php.ini setting. So the PHP script can run as long as required if that is set
sufficiently high enough. As long as you send something to the browser to
confirm that the process has started, the browser-side timeout will not be a
problem and your user will know to wait until notified by email that the file
is ready. Once the script has completed, it stores the final db record and
sends the email.
George
--- End Message ---
--- Begin Message ---
Is there a way to stream line this:
if ( ( $val <> "with" ) AND ( $val <> "from" ) ) {
Ron
The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info
--- End Message ---
--- Begin Message ---
if( $val !== "with" && $val !== "from")
simple comparison = faster solution... also you want type-safe
you could do something like
if(!in_array($val, array("from","with"))) but its neither elegant nor fast
On Jul 14, 2011 12:22 AM, "Ron Piggott" <[email protected]>
wrote:
--- End Message ---
--- Begin Message ---
That's already pretty streamlined...
On Jul 13, 2011 11:22 PM, "Ron Piggott" <[email protected]>
wrote:
>
> Is there a way to stream line this:
>
> if ( ( $val <> "with" ) AND ( $val <> "from" ) ) {
>
> Ron
>
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info
--- End Message ---
--- Begin Message ---
On 12 July 2011 18:45, Marc Guay <[email protected]> wrote:
> Hi folks,
>
> I'm working on a project that will only be run locally on a WAMP
> server. A mobile browser/app will call a certain page which should
> silently trigger a print job to a printer connected to the printer.
> Does anyone have advice on how to accomplish this? I've seen
> implementations involving Crystal Reports which will be available on
> the server, but perhaps someone has a solutions that won't involve 3rd
> party software.
>
> Marc
Several options come to mind.
1 - Use Crystal Reports Developer Edition (or an app that comes with
Crystal Reports RunTime and a non developer edition of CR). Maximum
version is XI R2. After that, there is no COM interface, only .NET and
Java - and I can't get the .NET interface to operate in the same way
as I can the COM interface.
2 - Create PDF files and use Acrobat Reader or some other PDF print
driver (CutePDF maybe) - ideally something that can be unattended. The
fpdf class (http://fpdf.org is what I use).
3 - If you are already using Windows, then maybe you have MS Office?
Another COM solution could be to use MS Word or MS Excel (depending
upon the nature of the reports you need.
4 - And just found it. WordPad comes with Windows, so, maybe
PHP+COM+WordPad
(http://msdn.microsoft.com/en-us/library/51y8h3tk(v=vs.80).aspx) could
be another option here. I think WordPad is just a visual wrapper for
the RichEdit20 ActiveX component which is controllable via COM.
By using templates, you could create appropriate files manually in
WordPad and then just do a search/replace in PHP, load into RichEdit
and print. Theoretically, a simple process.
Richard.
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
--- End Message ---