Google Groups Home
Help | Sign in
Select expressions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
robert henniger  
View profile
 More options 2 Jul, 18:15
From: robert henniger <robert.henni...@googlemail.com>
Date: Wed, 2 Jul 2008 10:15:28 -0700 (PDT)
Local: Wed 2 Jul 2008 18:15
Subject: Select expressions
Hi to all.
Is it possible to use mathematical operations and "extend" the
selected resultset with additional/virtual "fields?
Example:
SELECT *, (product_price * count_product) as sum_price FROM
shoppingcart

Thanks in advance.

Robert


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
robert henniger  
View profile
 More options 2 Jul, 18:19
From: robert henniger <robert.henni...@googlemail.com>
Date: Wed, 2 Jul 2008 10:19:29 -0700 (PDT)
Local: Wed 2 Jul 2008 18:19
Subject: Re: Select expressions
Additional Information:
I forgot the where condition:
SELECT *, (product_price * count_product) as sum_price FROM
shoppingcart WHERE sum_price > 50

Best regards
Robert

On 2 Jul., 19:15, robert henniger <robert.henni...@googlemail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile
(1 user)  More options 2 Jul, 19:32
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Wed, 2 Jul 2008 13:32:34 -0500
Local: Wed 2 Jul 2008 19:32
Subject: Re: [doctrine-user] Re: Select expressions

Yes.

- Jon

On Wed, Jul 2, 2008 at 12:19 PM, robert henniger <

--
Jonathan Wage
http://www.jwage.com
http://www.centresource.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
robert henniger  
View profile
 More options 3 Jul, 01:39
From: robert henniger <robert.henni...@googlemail.com>
Date: Wed, 2 Jul 2008 17:39:06 -0700 (PDT)
Local: Thurs 3 Jul 2008 01:39
Subject: Re: Select expressions
Hi Jon,
sorry but i dont understand.
Can you give me more information?

Robert

On 2 Jul., 20:32, "Jonathan Wage" <jonw...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile
(1 user)  More options 3 Jul, 04:28
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Wed, 2 Jul 2008 22:28:09 -0500
Local: Thurs 3 Jul 2008 04:28
Subject: Re: [doctrine-user] Re: Select expressions

DQL has the same ability to specify expressions like SQL can.

$q = Doctrine_Query::create()
          ->select('u.*, (u.num_posts / 24) as num_posts_per_day')
          ->from('User u')
          ->orderBy('num_posts_per_day asc');

$topPosters = $q->fetchArray();

Note: I didn't test the above code but I know that the concept works, so
their may be a typo or mistake or something. Give it a try.

- Jon

On Wed, Jul 2, 2008 at 7:39 PM, robert henniger <

--
Jonathan Wage
http://www.jwage.com
http://www.centresource.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
robert henniger  
View profile
 More options 3 Jul, 11:04
From: robert henniger <robert.henni...@googlemail.com>
Date: Thu, 3 Jul 2008 03:04:48 -0700 (PDT)
Local: Thurs 3 Jul 2008 11:04
Subject: Re: Select expressions
Thank you Jon,
it works now. I tested it yesterday but i think i did something wrong
then.
Sorry for that!
Can i use every "mysql" function for the expression or which functions
are supported?
I am asking because in mysql you use "rand()" and this will not work.
When i use "random()" it works.

Is there something i have to keep in mind?

Best regards

PS: By the way, doctrine rocks and is a perfect tool for me.
The learning phase is a bit long but it is very cool and i am looking
forward for the release.

On 3 Jul., 05:28, "Jonathan Wage" <jonw...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile
 More options 3 Jul, 14:56
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Thu, 3 Jul 2008 08:56:42 -0500
Local: Thurs 3 Jul 2008 14:56
Subject: Re: [doctrine-user] Re: Select expressions

Yes, you can. But, Doctrine is portable by default. This means that the only
things you are allowed to use are things which are portable and can work
across any dbms. If you wish to use a dbms specific function then you must
turn off portability.

- Jon

On Thu, Jul 3, 2008 at 5:04 AM, robert henniger <

--
Jonathan Wage
http://www.jwage.com
http://www.centresource.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google