ds->update using SQL?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ds->update using SQL?

Marc Pinnell-3
Trying to replicate a statement like this using DS:

UPDATE table SET field = field + 1 WHERE id = $number

Is there a way to do that?

site_ds->update(::teams)
        ->set(
            ::twins = ::twins + 1,
            ::tgf = ::tgf + $hscore,
            ::tga = ::tga + $ascore
                )
        ->where(::team_key = postparam('hometeam'))
        ->do


Throws an error on the "twins" line.

Marc Pinnell

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: ds->update using SQL?

Jolle Carlestam-2
2 apr. 2016 kl. 18:12 skrev Marc Pinnell <[hidden email]>:

>
> Trying to replicate a statement like this using DS:
>
> UPDATE table SET field = field + 1 WHERE id = $number
>
> Is there a way to do that?
>
> site_ds->update(::teams)
> ->set(
>    ::twins = ::twins + 1,
>    ::tgf = ::tgf + $hscore,
>    ::tga = ::tga + $ascore
> )
> ->where(::team_key = postparam('hometeam'))
> ->do
>
>
> Throws an error on the "twins" line.

I think you have to stick to the sql statement. Works perfectly fine in DS.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: ds->update using SQL?

Marc Pinnell-3
You lost me. What works in DS?

marc


On Apr 2, 2016, at 10:05 AM, Jolle Carlestam <[hidden email]> wrote:

> 2 apr. 2016 kl. 18:12 skrev Marc Pinnell <[hidden email]>:
>>
>> Trying to replicate a statement like this using DS:
>>
>> UPDATE table SET field = field + 1 WHERE id = $number
>>
>> Is there a way to do that?
>>
>> site_ds->update(::teams)
>> ->set(
>>    ::twins = ::twins + 1,
>>    ::tgf = ::tgf + $hscore,
>>    ::tga = ::tga + $ascore
>> )
>> ->where(::team_key = postparam('hometeam'))
>> ->do
>>
>>
>> Throws an error on the "twins" line.
>
> I think you have to stick to the sql statement. Works perfectly fine in DS.
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

Marc Pinnell
1027 Design
PO Box 990872
Redding, CA 96099-0872
530.941.4706
fax: 866.232.5300
www.1027Design.com



#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: ds->update using SQL?

Jolle Carlestam-2
2 apr. 2016 kl. 19:09 skrev Marc Pinnell <[hidden email]>:
>
> You lost me. What works in DS?

Why, SQL of course.

site_ds -> sql(”UPDATE teams SET twins = twins + 1, tgf = tgf + ” + $hscore -> encodesql + ” tga = tga + ” + $ascore -> encodesql + ” WHERE team_key = '” + postparam('hometeam’) -> encodesql + ”';”)

If $hscore and or $ascore are integers then change  -> encodesql to -> asinteger for those values.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: ds->update using SQL?

Marc Pinnell-3
Cool. I looked back and forth through the manual and didn't see the ->sql command. I thought I had seen that before, but could not locate it.

Thanks, that's perfect!

marc


On Apr 2, 2016, at 10:36 AM, Jolle Carlestam <[hidden email]> wrote:

> 2 apr. 2016 kl. 19:09 skrev Marc Pinnell <[hidden email]>:
>>
>> You lost me. What works in DS?
>
> Why, SQL of course.
>
> site_ds -> sql(”UPDATE teams SET twins = twins + 1, tgf = tgf + ” + $hscore -> encodesql + ” tga = tga + ” + $ascore -> encodesql + ” WHERE team_key = '” + postparam('hometeam’) -> encodesql + ”';”)
>
> If $hscore and or $ascore are integers then change  -> encodesql to -> asinteger for those values.
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

Marc Pinnell
1027 Design
PO Box 990872
Redding, CA 96099-0872
530.941.4706
fax: 866.232.5300
www.1027Design.com



#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: ds->update using SQL?

Ke Carlton-3
In reply to this post by Marc Pinnell-3
You're trying to add 1 to a ::tag — use this syntax:

ds->update(::teams)
->set(
   'twins = twins + 1',
   'tgf   = tgf + ' + $hscore,
   'tga   = tga + ' + $ascore,
)
->where(::team_key = postparam('hometeam'))
->do

With active_statements, pretty much all methods that accept pairs (which
are automatically encoded) can be supplied a raw SQL string instead — which
will not be encoded.

Ke

On Sun, Apr 3, 2016 at 4:12 AM Marc Pinnell <[hidden email]>
wrote:

> Trying to replicate a statement like this using DS:
>
> UPDATE table SET field = field + 1 WHERE id = $number
>
> Is there a way to do that?
>
> site_ds->update(::teams)
>         ->set(
>             ::twins                     =       ::twins + 1,
>             ::tgf                       =       ::tgf + $hscore,
>             ::tga                       =       ::tga + $ascore
>                 )
>         ->where(::team_key = postparam('hometeam'))
>         ->do
>
>
> Throws an error on the "twins" line.
>
> Marc Pinnell
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: ds->update using SQL?

Marc Pinnell-3
Cool. Thanks.

marc


On Apr 2, 2016, at 1:36 PM, Ke Carlton <[hidden email]> wrote:

> You're trying to add 1 to a ::tag — use this syntax:
>
> ds->update(::teams)
> ->set(
>   'twins = twins + 1',
>   'tgf   = tgf + ' + $hscore,
>   'tga   = tga + ' + $ascore,
> )
> ->where(::team_key = postparam('hometeam'))
> ->do
>
> With active_statements, pretty much all methods that accept pairs (which
> are automatically encoded) can be supplied a raw SQL string instead — which
> will not be encoded.
>
> Ke
>
> On Sun, Apr 3, 2016 at 4:12 AM Marc Pinnell <[hidden email]>
> wrote:
>
>> Trying to replicate a statement like this using DS:
>>
>> UPDATE table SET field = field + 1 WHERE id = $number
>>
>> Is there a way to do that?
>>
>> site_ds->update(::teams)
>>        ->set(
>>            ::twins                     =       ::twins + 1,
>>            ::tgf                       =       ::tgf + $hscore,
>>            ::tga                       =       ::tga + $ascore
>>                )
>>        ->where(::team_key = postparam('hometeam'))
>>        ->do
>>
>>
>> Throws an error on the "twins" line.
>>
>> Marc Pinnell
>>
>> #############################################################
>>
>> This message is sent to you because you are subscribed to
>>  the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

Marc Pinnell
1027 Design
PO Box 990872
Redding, CA 96099-0872
530.941.4706
fax: 866.232.5300
www.1027Design.com



#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>