[ds] Leaving Open MySQL Connections

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

[ds] Leaving Open MySQL Connections

Justin Dennis-3
I have noticed the following quirk with ds:

This properly closes the MySQL connection:

#customer = activerow(::db.customer)
*$customerID > 0 ? #customer->getrow($customerID)*
#customercontactlog = activerow(::db.customercontactlog)


If I move line 2 down:

#customer = activerow(::db.customer)
#customercontactlog = activerow(::db.customercontactlog)
*$customerID > 0 ? #customer->getrow($customerID)*


This leaves an open connection on MySQL ("sleep" state) every time it runs.

Any ideas why the syntax causes this behavior? Have I got this all wrong?

Thanks for any light you can shed.

- Justin

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

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] Leaving Open MySQL Connections

Ke Carlton-3
Thanks Justin, looks like you've found a bug — has been corrected.

I'd actually recommend creating types for your objects, very straight
forward:

define customer => type {
parent activerow
public ds => ds(::db.customer)
public oncreate(...) => ..oncreate(: #rest || staticarray)
}

I would also suggest defining a DS like so:

define some_ds => ds(::db)

From there you can leverage it in multiple types:

define customer => type {
parent activerow
public ds => some_ds->table(::customers)
public oncreate(...) => ..oncreate(: #rest || staticarray)

public log => customer_log(.id)
}

define customer_log => type {
parent activerow
public ds => some_ds->table(::customercontactlog)
public oncreate(customer_id::integer) => .getrow(::customer_id =
#customer_id)
}

This way you only have to update some_ds and everything else follows along.

Ke

On Thu, Jul 30, 2015 at 11:55 AM Justin Dennis <[hidden email]> wrote:

> I have noticed the following quirk with ds:
>
> This properly closes the MySQL connection:
>
> #customer = activerow(::db.customer)
> *$customerID > 0 ? #customer->getrow($customerID)*
> #customercontactlog = activerow(::db.customercontactlog)
>
>
> If I move line 2 down:
>
> #customer = activerow(::db.customer)
> #customercontactlog = activerow(::db.customercontactlog)
> *$customerID > 0 ? #customer->getrow($customerID)*
>
>
> This leaves an open connection on MySQL ("sleep" state) every time it runs.
>
> Any ideas why the syntax causes this behavior? Have I got this all wrong?
>
> Thanks for any light you can shed.
>
> - Justin
>
> #############################################################
>
> 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] Leaving Open MySQL Connections

Justin Dennis-3
Thanks, Ke. This will be a good opportunity for me to try using the type
approach as well. -Justin

On Wed, Jul 29, 2015 at 11:26 PM, Ke Carlton <[hidden email]> wrote:

> Thanks Justin, looks like you've found a bug — has been corrected.
>
> I'd actually recommend creating types for your objects, very straight
> forward:
>
> define customer => type {
> parent activerow
> public ds => ds(::db.customer)
> public oncreate(...) => ..oncreate(: #rest || staticarray)
> }
>
> I would also suggest defining a DS like so:
>
> define some_ds => ds(::db)
>
> From there you can leverage it in multiple types:
>
> define customer => type {
> parent activerow
> public ds => some_ds->table(::customers)
> public oncreate(...) => ..oncreate(: #rest || staticarray)
>
> public log => customer_log(.id)
> }
>
> define customer_log => type {
> parent activerow
> public ds => some_ds->table(::customercontactlog)
> public oncreate(customer_id::integer) => .getrow(::customer_id =
> #customer_id)
> }
>
> This way you only have to update some_ds and everything else follows along.
>
> Ke
>
> On Thu, Jul 30, 2015 at 11:55 AM Justin Dennis <[hidden email]> wrote:
>
> > I have noticed the following quirk with ds:
> >
> > This properly closes the MySQL connection:
> >
> > #customer = activerow(::db.customer)
> > *$customerID > 0 ? #customer->getrow($customerID)*
> > #customercontactlog = activerow(::db.customercontactlog)
> >
> >
> > If I move line 2 down:
> >
> > #customer = activerow(::db.customer)
> > #customercontactlog = activerow(::db.customercontactlog)
> > *$customerID > 0 ? #customer->getrow($customerID)*
> >
> >
> > This leaves an open connection on MySQL ("sleep" state) every time it
> runs.
> >
> > Any ideas why the syntax causes this behavior? Have I got this all wrong?
> >
> > Thanks for any light you can shed.
> >
> > - Justin
> >
> > #############################################################
> >
> > 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]>

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

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]>