|
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-help
lists.php.net
Date: Thu Feb 07 2008 - 01:37:39 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 7 Feb 2008 07:37:39 -0000 Issue 5279
Topics (messages 268805 through 268849):
Delete a document from lotus domino with CURL
268805 by: Fnutt
Recommendation for an XML class?
268806 by: Brian Dunning
268807 by: Nathan Nobbe
268811 by: Paul Scott
268812 by: Nathan Nobbe
Re: phpt or phpunit and why?
268808 by: Eric Butera
Re: Progressive answers from a php query?
268809 by: Martin Marques
Re: Recommended ORM for PHP
268810 by: Manuel Lemos
268829 by: Larry Garfield
268834 by: Nathan Nobbe
268841 by: Manuel Lemos
shopping carts
268813 by: nihilism machine
268814 by: Daniel Brown
268815 by: nihilism machine
268816 by: Daniel Brown
268817 by: Greg Donald
268818 by: Eric Butera
268822 by: Jason Pruim
268832 by: John Taylor-Johnston
268833 by: John Taylor-Johnston
Re: PHP Source code protection
268819 by: zerof
268836 by: John Taylor-Johnston
Re: PHP CLI Problem
268820 by: Chris
268821 by: Daniel Brown
PHP/mySQL question about groups
268823 by: Rob Gould
268824 by: Nathan Nobbe
268828 by: Bastien Koert
268830 by: Andrew Ballard
268835 by: Nathan Nobbe
268837 by: Andrew Ballard
268842 by: Warren Vail
Roadsend (was Re: PHP Source code protection)
268825 by: Bruce Cowin
PHP program to download sites
268826 by: Leonard Burton
268827 by: Nathan Nobbe
array problem with a zencart shipping module
268831 by: John Taylor-Johnston
268838 by: Nathan Nobbe
268839 by: John Taylor-Johnston
268840 by: Paul Scott
Exception handling in PHP
268843 by: Prabath Kumarasinghe
268844 by: Paul Scott
268846 by: Prabath Kumarasinghe
268848 by: Paul Scott
268849 by: Prabath Kumarasinghe
Multiple MySQL INSERT into loop
268845 by: Rob G
Passing object reference to session
268847 by: Michael Moyle
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
I am working on a script that log in, look for messages, download them
(including any attached files) and then deletes the message from a lotus
domino server. What I have access to is a simple web-gui that I access
throu CURL. So far I have been able to do the following:
Log in and save a cookie.
List all documents in my mailbox (as a xml)
This gives me a list of all documents and their id-numbers so I can...
Open all document (one at a time) and save them to disc (using this url)
http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?OpenDocument
Where $path is the cookie-value (don't know if I need it but it works)
And $unid is the documents unique ID.
?OpenDocument opens the document.
Save any attachments found in the saved document (just downloading any
file that are linked in the document).
So far it's all good but now things get strange...
Delete the document, if I browse the domino-server with explorer, I can
just enter an url like the following:
http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?DeleteDocument
This does delete the document from the server, no problem at all but
once I try to do the same with CURL, I get a page that look like this:
----------------------------------------------
Response Message
HTTP Web Server: Invalid URL Exception
Go Back
----------------------------------------------
If I put Delete (which also works in explorer instead of DeleteDocument)
the error message change to:
HTTP Web Server: Unknown Command Exception
I find this most frustrating since all my other url-requests work out well.
I'm greatful for any help I can get on this matter.
------------------------------------------------------------------------
Some more information on how I do this:
OpenDocument:
$fp2 = fopen("/tmp/files_from_lotus/$filename.html","w");
$curl = curl_init();
curl_setopt($curl, CURLOPT_FILE, $fp2);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1)");
curl_setopt($curl, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
curl_setopt($curl, CURLOPT_URL,
"http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?OpenDocument");
curl_exec($curl);
curl_close($curl);
fclose ($fp2);
DeleteDocument: (doesn't work)
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1)");
curl_setopt($curl, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
curl_setopt($curl, CURLOPT_URL,
"http://000.000.000.000/mail/mapp/databas.nsf/$path/$unid?DeleteDocument");
curl_exec($curl);
curl_close($curl);
attached mail follows:
I see there are billions of XML classes out there. Can anyone
recommend one that's good & simple? My needs are quite basic, all I
really need is to draw simple values out of the XML, like convert
<order_no>123</order_no> to $order_no = 123.
Thanks...
attached mail follows:
On Feb 6, 2008 3:09 PM, Brian Dunning <brian
briandunning.com> wrote:
> I see there are billions of XML classes out there. Can anyone
> recommend one that's good & simple? My needs are quite basic, all I
> really need is to draw simple values out of the XML, like convert
> <order_no>123</order_no> to $order_no = 123.<http://www.php.net/unsub.php>
SimpleXML,
http://www.php.net/manual/en/ref.simplexml.php
-nathan
attached mail follows:
On Wed, 2008-02-06 at 15:12 -0500, Nathan Nobbe wrote:
> SimpleXML,
> http://www.php.net/manual/en/ref.simplexml.php
>
Dude, I thought you were playing with SPL! SimpleXML _then_ use the
SimpleXMLIterator to work with it!
http://www.php.net/spl
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
attached mail follows:
On Feb 6, 2008 4:04 PM, Paul Scott <pscott
uwc.ac.za> wrote:
> Dude, I thought you were playing with SPL! SimpleXML _then_ use the
> SimpleXMLIterator to work with it!
>
> http://www.php.net/spl
well of course; if you need to flatten out an xml structure in
a few lines of code ;)
-nathan
attached mail follows:
On Feb 6, 2008 1:32 PM, Nathan Nobbe <quickshiftin
gmail.com> wrote:
> in a conversation on #gentoo-php (irc), the following distinction
> was drawn,
>
> " back on the phpt; just curious, how do you see it compared to something
> like phpunit ?
> comparable, or different.."
>
> " different... phpt is probably really mostly intended for testing php and
> their extensions
> phpunit rather for testing code written in php"
>
> -nathan
>
This might be of interest:
http://talks.somabo.de/200703_montreal_need_for_testing.pdf
You can also see his other talks here: http://talks.somabo.de/
Right now I use Simpletest because I'm heavily invested in it.
PHPUnit is looking better every day though... :)
attached mail follows:
Richard escribió:
> Hello, I don't know if this is possible with PHP alone but this is what
> I'm trying to do :
>
> My script would check say for example 10 or 20 different http:// site
> addresses and collect some text from each page.
>
> My problem is that it takes quite a long time to query so many sites,
> and the user would have to wait for un to 30 sec to 1 min before the
> page comes up ...
>
> So there are two ways I can think of inorder to reduce the waiting time.
>
> 1) Perform asynchronous searches at the same time so all details are
> collected at the same time instead of waiting for the script to collect
> data from each one, one by one.
>
> 2) Somehow show data as it arrives instead of waiting for all the
> queries to be done.
>
> Is it possible to do either of these two, or both of these two with only
> PHP? If so how would I do it?
>
> or is it necessary to use javascript?
I think it's best to do this on the client side. If you want to have
something done on the server, then at least use AJAX so the page gets
loaded on demand.
attached mail follows:
on 02/06/2008 11:10 AM js said the following:
> Hi list,
>
> When creating a LAMP app, I always start by writing ORM myself.
> It's fun but it usually takes a long time.
> Besides, that always results in a toy-system,
> I mean, that has not so many features, not so efficient non-bug-free.
>
> I started to think that now is the time to throw away my rubbish
> and use more effective Open source ORM.
>
> So my question is what ORM are you using?
> What ORM do you recommend?
> There're lots of Web app frameworks out there
> but I could't find simple ORM in PHP.
A similar question was asked here a couple of days ago.
I will be repeating myself, but what I said was that I use Metatsorage
which is an ORM class generator tool. It is a different approach than
others you may find. It generates persistent object classes that are
smaller and more efficient.
You may find more about Metastorage here:
http://www.meta-language.net/metastorage.html
Here you may find a small example application:
http://www.meta-language.net/metanews.html
Here you may see some screenshots of the Web user interface of the
generator tool and screenshots of the applications:
http://www.meta-language.net/screenshots.html
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
attached mail follows:
On Wednesday 06 February 2008, Edward Kay wrote:
> Have a look at Qcodo. http://www.qcodo.com.
>
> It uses code generation to create your ORM for you direct from the DB
> tables. As it's code generation as opposed to run time analysis (which is
> what ActiveRecord and the like use), there is no performance hit - it
> literally just creates your PHP class files for you.
Uh, lots of Active Record systems use code generation. If the structure of
your data abstraction is based on the database structure, then you're using
Active Record. It's record-centric. If you're using an object-centric view
of the world that may just happen to tie to an SQL database for its data
store, then it's an ORM.
Both are useful in different circumstances, but whether or not there is code
generation has nothing to do with whether it's AR or ORM.
--
Larry Garfield AIM: LOLG42
larry
garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
attached mail follows:
On Feb 6, 2008 10:59 PM, Larry Garfield <larry
garfieldtech.com> wrote:
> On Wednesday 06 February 2008, Edward Kay wrote:
> > Have a look at Qcodo. http://www.qcodo.com.
> >
> > It uses code generation to create your ORM for you direct from the DB
> > tables. As it's code generation as opposed to run time analysis (which
> is
> > what ActiveRecord and the like use), there is no performance hit - it
> > literally just creates your PHP class files for you.
>
> Uh, lots of Active Record systems use code generation. If the structure
> of
> your data abstraction is based on the database structure, then you're
> using
> Active Record. It's record-centric. If you're using an object-centric
> view
> of the world that may just happen to tie to an SQL database for its data
> store, then it's an ORM.
>
> Both are useful in different circumstances, but whether or not there is
> code
> generation has nothing to do with whether it's AR or ORM.
>
well i think its worth a mention that qcodo has an article that
distinguishes
'ActiveRecord classes' from the 'ActiveRecord pattern'.
http://www.qcodo.com/documentation/article.php/6
what it mainly says is that code generation increases performance over
runtime
analysis of some model; eg. the database schema or perhaps some other
representation, such as xml (or yaml [apparently ;)]). the article also
classifies
ruby on rails as one of these obfusticators of fowlers original pattern;
greg, thoughts ?
anyway, im not sure i agree with the distinction of code-generation vs.
metaprogramming;
i sort of see them overlapping.
and also, on the original topic of the thread; there was just another thread
on this the
other day; check out propel and doctrine; and said thread ;)
http://marc.info/?l=php-general&m=120215073929527&w=2
-nathan
attached mail follows:
Hello,
on 02/07/2008 02:18 AM Nathan Nobbe said the following:
> well i think its worth a mention that qcodo has an article that
> distinguishes
> 'ActiveRecord classes' from the 'ActiveRecord pattern'.
> http://www.qcodo.com/documentation/article.php/6
> what it mainly says is that code generation increases performance over
> runtime
> analysis of some model; eg. the database schema or perhaps some other
> representation, such as xml (or yaml [apparently ;)]). the article also
> classifies
> ruby on rails as one of these obfusticators of fowlers original pattern;
> greg, thoughts ?
Yes, 6 years ago I analyzed the approaches of many these solutions that
analyze database schemas at run-time and cache the results . I concluded
that is not by far as efficient as a full code generation based solution.
A code generation based solution will generate code that does what is
necessary without any additional run-time libraries.
Those caching solutions still need to read cached information and
interpret what is cached. Not only they spend more time but also more
memory, especially if you need to load a pile of classes to load your
caching engine and run-time interpreter.
Another problem I found in those solutions is that often you need to
inherit from a fat base class that implements all sorts of functionality
that you may need at run-time to perform object-relational mapping
operations, even if your application objects do not need all that
functionality.
I concluded that it would be more efficient to generate root classes
that just include the functionality you have. For instance, if you do
not need to delete objects from you application, there is no sense in
having that functionality in your objects. The results is persistent
classes that do not inherit from fat base classes and are much thiner
and faster to load and execute.
Yet another problem of the solutions that defer mapping to runtime
libraries is the composition of queries with conditions that need to be
composed at run time.
I concluded that is much more efficient to have an object query language
(OQL) that lets you define the conditions of your queries. These
queries are processed at compile time and the compiler generates
efficient SQL code that does not need to be composed at run time.
Your applications just call a single function to execute object queries
that satisfy the conditions that you defined. This results again is much
thiner and faster code that does *Just Exactly What You Need* (_JEWYN_).
All these details that I mentioned have been implemented by Metastorage,
which is an ORM code generation tool.
http://www.metastorage.net/
The generated code is very satisfying because it looks exactly like what
I would write if I had to do it manually, except that I did not have to
spend a lot time writing it. I just defined my business objects a simple
model file that describes the classes, relationships, validation rules,
and functions I need to manipulate those objects.
The compile time is measured in a few seconds. The time this tool took
to develop is paying more and more on every application feature I need
to implement but I do not need to waste hours or days coding the
persistent object classes.
There are more details about the Metastorage approaches to each problem
on the FAQ if you are interested:
http://www.meta-language.net/metastorage-faq.html
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
attached mail follows:
Does anyone know of a shopping cart which allows you to add multiple
custom fields to each product?
--e
attached mail follows:
On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachine
gmail.com> wrote:
> Does anyone know of a shopping cart which allows you to add multiple
> custom fields to each product?
http://www.hotscripts.com/
http://php.resourceindex.com/
http://www.sf.net/
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
that does not help, none specify whether they have a custom fields
option or not.
On Feb 6, 2008, at 4:23 PM, Daniel Brown wrote:
> On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachine
gmail.com>
> wrote:
>> Does anyone know of a shopping cart which allows you to add multiple
>> custom fields to each product?
>
> http://www.hotscripts.com/
> http://php.resourceindex.com/
> http://www.sf.net/
>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
On Feb 6, 2008 4:26 PM, nihilism machine <nihilismmachine
gmail.com> wrote:
> that does not help, none specify whether they have a custom fields
> option or not.
Neither does a "PHP mailing list." Search Google. Then, read the
description of the shopping cart software.
The best options I can think of are osCommerce, ZenCart, and
XCart. If I remember correctly, they all allow custom fields.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
On 2/6/08, nihilism machine <nihilismmachine
gmail.com> wrote:
> that does not help, none specify whether they have a custom fields
> option or not.
"Wah.. why won't anyone do my research for me?"
--
Greg Donald
http://destiney.com/
attached mail follows:
On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachine
gmail.com> wrote:
> Does anyone know of a shopping cart which allows you to add multiple
> custom fields to each product?
> --e
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Please do not use osCommerce.
attached mail follows:
On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:
> On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachine
gmail.com>
> wrote:
>> Does anyone know of a shopping cart which allows you to add multiple
>> custom fields to each product?
>> --e
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Please do not use osCommerce.
Umm, Can I ask why? I just downloaded it a few days ago to play with
it on my server. I don't need it myself, but something good to have in
the arsenal :)
attached mail follows:
zencart is giving me every possible custom field I can dream of.
John
Jason Pruim wrote:
>
> On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:
>
>> On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachine
gmail.com>
>> wrote:
>>> Does anyone know of a shopping cart which allows you to add multiple
>>> custom fields to each product?
>>> --e
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Please do not use osCommerce.
>
> Umm, Can I ask why? I just downloaded it a few days ago to play with it
> on my server. I don't need it myself, but something good to have in the
> arsenal :)
attached mail follows:
zencart is giving me every possible custom field I can dream of.
John
Jason Pruim wrote:
>
> On Feb 6, 2008, at 5:56 PM, Eric Butera wrote:
>
>> On Feb 6, 2008 4:18 PM, nihilism machine <nihilismmachine
gmail.com>
>> wrote:
>>> Does anyone know of a shopping cart which allows you to add multiple
>>> custom fields to each product?
>>> --e
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Please do not use osCommerce.
>
> Umm, Can I ask why? I just downloaded it a few days ago to play with it
> on my server. I don't need it myself, but something good to have in the
> arsenal :)
attached mail follows:
Zoran Bogdanov escreveu:
> Hi,
>
> I'm building a C# application that connects to a server that has PHP scripts
> on it.
>
> We need to deliver the complete solution to a firm, the C# is no problem
> because it is compiled...
>
> But PHP is a problem bacause it is interpreted and we will have to deliver
> pure, unprotected script...
>
> Is htere a way to secoure my code so when they put it on the server, they
> can't see it!
>
> Thank You!
Try Roadsend, now as Open Source:
http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
----------------------------------------------------------
You must hear, always, one second opinion! In all cases.
----------------------------------------------------------
Let the people know if this info was useful for you!
----------------------------------------------------------
attached mail follows:
I'm not sure where PHP stands on this politically. But I believe in Open
Source, which allows you to encode your code. But why? At heart I'm a
purist GNU. Stallman was right when he first tried to fix a faulty printer.
* The freedom to run the program, for any purpose (freedom 0).
* The freedom to study how the program works, and adapt it to your
needs (freedom 1). Access to the source code is a precondition for this.
* The freedom to redistribute copies so you can help your neighbor
(freedom 2).
* The freedom to improve the program, and release your improvements
to the public, so that the whole community benefits (freedom 3). Access
to the source code is a precondition for this.
Thankfully there is little that cannot be reversed engineered. If you
want to keep the recipe, host it yourself and let others use an interface.
This is stepping in a nest of hornets. :p
C.R.Vegelin wrote:
> See also:
> http://www.ioncube.com/
>
>
> ----- Original Message ----- From: "Bastien Koert" <bastien_k
hotmail.com>
> To: "Zoran Bogdanov" <test1.test1
hi.t-com.hr>; <php-general
lists.php.net>
> Sent: Wednesday, February 06, 2008 2:27 PM
> Subject: RE: [PHP] PHP Source code protection
>
>
>
> zend encoder?
> http://sourceforge.net/projects/php-screw/
>
>
> google for more
>
>
>
> bastien> To: php-general
lists.php.net> From: test1.test1
hi.t-com.hr>
> Date: Wed, 6 Feb 2008 12:28:12 +0100> Subject: [PHP] PHP Source code
> protection> > Hi,> > I'm building a C# application that connects to a
> server that has PHP scripts > on it.> > We need to deliver the complete
> solution to a firm, the C# is no problem > because it is compiled...> >
> But PHP is a problem bacause it is interpreted and we will have to
> deliver > pure, unprotected script...> > Is htere a way to secoure my
> code so when they put it on the server, they > can't see it!> > Thank
> You! > > -- > PHP General Mailing List (http://www.php.net/)> To
> unsubscribe, visit: http://www.php.net/unsub.php>
> _________________________________________________________________
attached mail follows:
> In your cronjob, replace the php5 entry with the following
> (including the backticks):
> `which php5`
>
> If that still doesn't work, replace it simply with php, not php5:
> `which php`
You can use 'env php' instead and it'll pick up the first one in $PATH
(same sort of idea as 'which' though).
So the job would be:
env php -f /path/to/file.php
Also while the curl suggestion may work, it's going to (eventually) have
timeout issues and stop working if the backup's become too large.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
On Feb 6, 2008 6:56 PM, Chris <dmagick
gmail.com> wrote:
>
> > In your cronjob, replace the php5 entry with the following
> > (including the backticks):
> > `which php5`
> >
> > If that still doesn't work, replace it simply with php, not php5:
> > `which php`
>
> You can use 'env php' instead and it'll pick up the first one in $PATH
> (same sort of idea as 'which' though).
>
> So the job would be:
>
> env php -f /path/to/file.php
>
> Also while the curl suggestion may work, it's going to (eventually) have
> timeout issues and stop working if the backup's become too large.
Unless then you employ ignore_user_abort(1); et al.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Let's say I have a PHP-based wine application, and it's taking a set of mySQL data that looks like this:
wineid name size
123 Silver Oak 750ML
123 Silver Oak 1.5L
123 Silver Oak 1.5L
456 Liberty School 750ML
456 Liberty School 750ML
456 Liberty School 750ML
456 Liberty School 1.5L
If I do a:
Select * from wine where name = 'Silver Oak' GROUP BY 'wineid'
I'd get:
Silver Oak
However, what I'd REALLY like to return is:
Silver Oak 750ML
Silver Oak 1.5L
I'd like the groupby to group by wineid, BUT ALSO separate the groups by 'size'. So there'd be a '750ML' group, and a '1.5L' group
Can anyone tell me how I'd do that? I'm hoping I don't have to write a PHP script that loops through the results and separates things manually.
attached mail follows:
On Feb 6, 2008 8:46 PM, Rob Gould <gouldimg
mac.com> wrote:
> Let's say I have a PHP-based wine application, and it's taking a set of
> mySQL data that looks like this:
>
> wineid name
> size
> 123 Silver Oak
> 750ML
> 123 Silver Oak
> 1.5L
> 123 Silver Oak
> 1.5L
> 456 Liberty School
> 750ML
> 456 Liberty School
> 750ML
> 456 Liberty School
> 750ML
> 456 Liberty School
> 1.5L
>
i think you can just do
group by wineid, size
-nathan
attached mail follows:
Select * from wine where name = 'Silver Oak' GROUP BY wineid,size
bastien> Date: Wed, 6 Feb 2008 17:46:52 -0800> From: gouldimg
mac.com> To: php-general
lists.php.net> Subject: [PHP] PHP/mySQL question about groups> > Let's say I have a PHP-based wine application, and it's taking a set of mySQL data that looks like this:> > wineid name size > 123 Silver Oak 750ML> 123 Silver Oak 1.5L> 123 Silver Oak 1.5L> 456 Liberty School 750ML> 456 Liberty School 750ML> 456 Liberty School 750ML> 456 Liberty School 1.5L> > > If I do a:> > Select * from wine where name = 'Silver Oak' GROUP BY 'wineid'> > I'd get:> > Silver Oak> > > However, what I'd REALLY like to return is:> > Silver Oak 750ML> Silver Oak 1.5L> > I'd like the groupby to group by wineid, BUT ALSO separate the groups by 'size'. So there'd be a '750ML' group, and a '1.5L' group> > Can anyone tell me how I'd do that? I'm hoping I don't have to write a PHP script that loops through the results and separates things manually.> > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>
_________________________________________________________________
attached mail follows:
On Feb 6, 2008 8:46 PM, Rob Gould <gouldimg
mac.com> wrote:
> Let's say I have a PHP-based wine application, and it's taking a set of mySQL data that looks like this:
>
> wineid name size
> 123 Silver Oak 750ML
> 123 Silver Oak 1.5L
> 123 Silver Oak 1.5L
> 456 Liberty School 750ML
> 456 Liberty School 750ML
> 456 Liberty School 750ML
> 456 Liberty School 1.5L
>
>
> If I do a:
>
> Select * from wine where name = 'Silver Oak' GROUP BY 'wineid'
>
> I'd get:
>
> Silver Oak
>
>
> However, what I'd REALLY like to return is:
>
> Silver Oak 750ML
> Silver Oak 1.5L
>
> I'd like the groupby to group by wineid, BUT ALSO separate the groups by 'size'. So there'd be a '750ML' group, and a '1.5L' group
>
> Can anyone tell me how I'd do that? I'm hoping I don't have to write a PHP script that loops through the results and separates things manually.
>
That's something MySQL will allow that IMO it should not. Being able
to use SELECT * and GROUP BY at the same time can create confusion as
it did here. The other suggestions would probably work, but a good
rule of thumb is not to use any columns in the SELECT clause unless
they are either included in the GROUP BY clause or else use one of the
aggregate functions like COUNT, SUM, AVG, etc. (I'm not sure of the
actual SQL standard on this point, but SQL Server insists on it.)
SELECT name, size
FROM wine
GROUP BY name, size
Of course, in this case you could just avoid all the confusion with
this statement as well:
SELECT DISTINCT name, size
FROM wine
Andrew
attached mail follows:
On Feb 6, 2008 10:59 PM, Andrew Ballard <aballard
gmail.com> wrote:
> Of course, in this case you could just avoid all the confusion with
> this statement as well:
>
> SELECT DISTINCT name, size
> FROM wine
im not sure why, but i think distinct is typically way slower than group by.
-nathan
attached mail follows:
On Feb 6, 2008 11:20 PM, Nathan Nobbe <quickshiftin
gmail.com> wrote:
> On Feb 6, 2008 10:59 PM, Andrew Ballard <aballard
gmail.com> wrote:
>
> > Of course, in this case you could just avoid all the confusion with
> > this statement as well:
> >
> > SELECT DISTINCT name, size
> > FROM wine
>
> im not sure why, but i think distinct is typically way slower than group by.
>
> -nathan
>
I can't really say for MySQL, but in my experience I'd say "it
depends." It seems to me that for this case they should be about the
same, as it's always been my thinking that GROUP BY did a DISTINCT
implicitly. However, I don't really know the internals of any DB
platform so I can't confirm that. I ran DESCRIBE on a couple different
tables, and they both return the same plan. I don't see any notable
difference in the queries either. However, I'll leave it to the OP to
test and see if one is better for his question.
Andrew
attached mail follows:
I did some looking into performance issues many years ago at company that
developed and marketed another database server, comparing the query plan to
the actual code, and a query plan usually shows the processes that consume
the major amount of time, disk I/O, index or table searches and such, but
doesn't show time consumed comparing, discriminating, and totaling, mostly
because they are negligible.
On the other hand distinct depends on comparison of all columns and will
have no help in reducing row counts unless accompanied by an order by
clause, where as group by implys an orderby and can be faster if indexes are
available for use in row ordering, and while the same totaling occurs,
comparison is limited to the columns specified in the group by.
The biggest impact on one or the other would be a well placed index, but for
the most part they should be about the same.
Warren Vail
-----Original Message-----
From: Andrew Ballard [mailto:aballard
gmail.com]
Sent: Wednesday, February 06, 2008 8:41 PM
To: PHP General list
Subject: Re: [PHP] PHP/mySQL question about groups
On Feb 6, 2008 11:20 PM, Nathan Nobbe <quickshiftin
gmail.com> wrote:
> On Feb 6, 2008 10:59 PM, Andrew Ballard <aballard
gmail.com> wrote:
>
> > Of course, in this case you could just avoid all the confusion with
> > this statement as well:
> >
> > SELECT DISTINCT name, size
> > FROM wine
>
> im not sure why, but i think distinct is typically way slower than group
by.
>
> -nathan
>
I can't really say for MySQL, but in my experience I'd say "it depends." It
seems to me that for this case they should be about the same, as it's always
been my thinking that GROUP BY did a DISTINCT implicitly. However, I don't
really know the internals of any DB platform so I can't confirm that. I ran
DESCRIBE on a couple different tables, and they both return the same plan. I
don't see any notable difference in the queries either. However, I'll leave
it to the OP to test and see if one is better for his question.
Andrew
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
attached mail follows:
>>> zerof <zerof
terra.com.br> 7/02/2008 12:04 p.m. >>>
Try Roadsend, now as Open Source:
http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler
Hey, that looks cool. Do many people use this? Has anyone built any
standalone GUI apps with it?
Regards,
Bruce
attached mail follows:
HI All,
I have a client who wants to be able to download/cache all web files
on certain sites for archiving info (i.e. before purchases, anything
where a record of what exactly was on a certain page is needed). They
would like to have this on the web server so employees could log in
and enter the sites for caching and then it can have a cron job and do
this at night.
Is there an OS program that will take a url and crawl/cache all the links on it?
If so I can easily create the interface, job queuing, and chron job setup.
Thanks,
--
Leonard Burton, N9URK
http://www.jiffyslides.com
service
jiffyslides.com
leonardburton
gmail.com
"The prolonged evacuation would have dramatically affected the
survivability of the occupants."
attached mail follows:
On Feb 6, 2008 9:30 PM, Leonard Burton <leonardburton
gmail.com> wrote:
> HI All,
>
> I have a client who wants to be able to download/cache all web files
> on certain sites for archiving info (i.e. before purchases, anything
> where a record of what exactly was on a certain page is needed). They
> would like to have this on the web server so employees could log in
> and enter the sites for caching and then it can have a cron job and do
> this at night.
>
> Is there an OS program that will take a url and crawl/cache all the links
> on it?
check out the recursive option for wget; its pretty sweet ;)
http://linuxreviews.org/quicktips/wget/
-nathan
attached mail follows:
I'm desperately going outside the forum, seeking help.
Does anyone have any experience with Zencart shipping modules, or
understand arrays?
http://www.zen-cart.com/forum/showthread.php?t=87831
Its borrowed code and I,m not good at arrays to begin with.
Thanks,
John
attached mail follows:
On Feb 6, 2008 11:11 PM, John Taylor-Johnston <jt.johnston
usherbrooke.ca>
wrote:
> I'm desperately going outside the forum, seeking help.
> Does anyone have any experience with Zencart shipping modules, or
> understand arrays?
> http://www.zen-cart.com/forum/showthread.php?t=87831
maybe you should stick w/ that ajeh guy; he seems like he knows what hes
talking about.
also, people here dont typically just hand out help on generic questions
such as this; if you can get a specific question about php or a more focused
question than please help i dont know much about arrays, then maybe we
can help out..
<http://www.zen-cart.com/forum/showthread.php?t=87831>
> Its borrowed code and I,m not good at arrays to begin with.
ouch, maybe you need to hire someone ? besides this has more to do than
just arrays; there is the rest of the application and clearly anyone whos
going
to help out must understand at least some of it..
-nathan
attached mail follows:
Thanks for the reply and checking it out.
I was hoping my problem lies only in the class.
I do have a Paypal account and at this point in time, it is a question
of time - I've got to get my site in production and shut off the old cart.
Nathan Nobbe wrote:
> On Feb 6, 2008 11:11 PM, John Taylor-Johnston
> <jt.johnston
usherbrooke.ca <mailto:jt.johnston
usherbrooke.ca>> wrote:
>
> I'm desperately going outside the forum, seeking help.
> Does anyone have any experience with Zencart shipping modules, or
> understand arrays?
> http://www.zen-cart.com/forum/showthread.php?t=87831
>
>
> maybe you should stick w/ that ajeh guy; he seems like he knows what hes
> talking about.
> also, people here dont typically just hand out help on generic questions
> such as this; if you can get a specific question about php or a more
> focused
> question than please help i dont know much about arrays, then maybe we
> can help out..
>
> Its borrowed code and I,m not good at arrays to begin with.
>
>
> ouch, maybe you need to hire someone ? besides this has more to do than
> just arrays; there is the rest of the application and clearly anyone
> whos going
> to help out must understand at least some of it..
>
> -nathan
>
attached mail follows:
On Wed, 2008-02-06 at 23:42 -0500, Nathan Nobbe wrote:
> ouch, maybe you need to hire someone ? besides this has more to do than
> just arrays; there is the rest of the application and clearly anyone whos
> going
> to help out must understand at least some of it..
Yeah, I concur! You really should at least understand what you are doing
before attempting a shopping cart scenario where presumably people are
going to be trusting you/your code with their hard earned dough.
If you don't know arrays, then how exactly are you going to make sure
that the thing is secure?
I would _seriously_ consider taking Nathan's advice here and hiring
someone to do this for you or even with you. With you has the advantage
that next time, you will know, and be able to do it easier - as well as
learn something along the way.
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
attached mail follows:
Hi All
I'm little bit confusing with PHP exception handling.
Could you able to explain how to put try{} and
catch(){} in a proper way in PHP. I had already read
php exception manual but it didn't help me to get
exact idea about exception handling in php.
Cheers
Prabath
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
attached mail follows:
On Wed, 2008-02-06 at 22:52 -0800, Prabath Kumarasinghe wrote:
> Hi All
>
> I'm little bit confusing with PHP exception handling.
> Could you able to explain how to put try{} and
> catch(){} in a proper way in PHP. I had already read
> php exception manual but it didn't help me to get
> exact idea about exception handling in php.
>
Well, its pretty simple really...
In your objects that you create, just put in a statement that throws an
exception of some sort (I like to extend the built in exception handler
with a custom one that deals properly with db errors as well as PHP
ones) and then try{} and catch(){} them in your business logic.
example:
class someclass {
public function foo()
{
// do something
...
else {
throw new Exception("uh-oh - we have a problem!");
}
}
}
$thing = new someclass;
try {
$thing->foo();
}
catch(Exception $e) {
echo $e->getMessage();
exit;
}
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
attached mail follows:
Hi Paul
Is this following code work in PHP if mysql_connect
fails.
try{
mysql_connect('localhost','user','');
}catch(Exception $e){
echo $e->getMessage();
}
Cheers
Prabath
--- Paul Scott <pscott
uwc.ac.za> wrote:
>
> On Wed, 2008-02-06 at 22:52 -0800, Prabath
> Kumarasinghe wrote:
> > Hi All
> >
> > I'm little bit confusing with PHP exception
> handling.
> > Could you able to explain how to put try{} and
> > catch(){} in a proper way in PHP. I had already
> read
> > php exception manual but it didn't help me to get
> > exact idea about exception handling in php.
> >
>
> Well, its pretty simple really...
>
> In your objects that you create, just put in a
> statement that throws an
> exception of some sort (I like to extend the built
> in exception handler
> with a custom one that deals properly with db errors
> as well as PHP
> ones) and then try{} and catch(){} them in your
> business logic.
>
> example:
>
> class someclass {
>
> public function foo()
> {
> // do something
> ...
> else {
> throw new Exception("uh-oh - we have a
> problem!");
> }
> }
>
> }
>
> $thing = new someclass;
> try {
> $thing->foo();
> }
> catch(Exception $e) {
> echo $e->getMessage();
> exit;
> }
>
> --Paul
>
> > All Email originating from UWC is covered by
> disclaimer
>
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
>
> > --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
attached mail follows:
On Wed, 2008-02-06 at 23:10 -0800, Prabath Kumarasinghe wrote:
> Is this following code work in PHP if mysql_connect
> fails.
>
> try{
> mysql_connect('localhost','user','');
>
> }catch(Exception $e){
> echo $e->getMessage();
>
Probably not. I don't think that the mysql functions throw exceptions on
failure.
You will have to write a wrapper function to do the exception on
failure, so something like
function dbConnect()
{
$conn = mysql_connect('','','');
if(!$conn) {
throw new Exception("Couldn't connect");
}
else {
return $conn;
}
}
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
attached mail follows:
Does that mean for every exception do we have to write
our custom exception and describe it from our own
message
Cheers
Prabath
--- Paul Scott <pscott
uwc.ac.za> wrote:
>
> On Wed, 2008-02-06 at 23:10 -0800, Prabath
> Kumarasinghe wrote:
> > Is this following code work in PHP if
> mysql_connect
> > fails.
> >
> > try{
> > mysql_connect('localhost','user','');
> >
> > }catch(Exception $e){
> > echo $e->getMessage();
> >
>
> Probably not. I don't think that the mysql functions
> throw exceptions on
> failure.
>
> You will have to write a wrapper function to do the
> exception on
> failure, so something like
>
> function dbConnect()
> {
> $conn = mysql_connect('','','');
> if(!$conn) {
> throw new Exception("Couldn't connect");
> }
> else {
> return $conn;
> }
> }
>
> > All Email originating from UWC is covered by
> disclaimer
>
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
attached mail follows:
I'm working on this, and am not sure how the variable syntax needs to be
here.
This is what I have done manually.
//BEGIN EXAMPLE
mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_1',
'$entry_1', '$name_1')");
mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_2',
'$entry_2', '$name_2')");
mysql_query ("INSERT INTO testimonials (id, quote, name) VALUES ('$id_3',
'$entry_3', '$name_3')");
//END EXAMPLE
I'd like to put this into a loop, so that the variable that are being
defined as the VALUES change as needed.
//BEGIN EXAMPLE
while ($i<16)
{
$i++;
mysql_query ("INSERT INTO testimonials (id,quote,name) VALUES ('$id_1',
'$entry_1', '$name_1')");)");
}
//END EXAMPLE
What I'm trying to figure out, is exactly how I need to format my entry
within the VALUES section, so that it will change based on the value of $i.
attached mail follows:
Hi,
I am new to the list and have a question that inspired me to join the
list as I can not find any answer online.
When a object reference is passed to the $_SESSION array what happens to
the object? Is the object serialized and saved in session (in this case
file)? Or just the reference with the object in memory remaining on the
heap?
--
best regards,
Michael
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]