[Xerte-dev] Re: Problem with Number of uses count in both trunk and v2.0

Pat @ Pgogy xerte at pgogywebstuff.com
Sat Jun 29 22:23:25 BST 2013


Why not update but with a where on template id

I think adding a select in to look for null is ok

On 29 Jun 2013, at 22:09, "Smith, John" <J.J.Smith at gcu.ac.uk> wrote:

> Hi,
> 
> I've noticed (and fixed) a bug which has been introduced into v2.0 (and probably before) where 'number_of_uses' in templatedetails is setup with default of NULL and was not being set to 0 when a new template was created. In this situation the play code query which runs number_of_uses=number_of_uses+1 doesn't work and the value stays as NULL...
> 
> So I've fixed it so that when new ones are created that 0 is inserted in this field but existing ones are stuck in limbo... I thought about fixing it in upgrade.php but have come up with what seems to me to be an elegant solution in play.php. I've changed the UPDATE query to:
> 
>    SET number_of_uses=COALESCE(number_of_uses+1,1)
> 
> which seems to work. Basically COALESCE returns the first value that isn't NULL... so if number_of_uses is NULL then so it the +1 so in that case it returns the second value of 1.
> 
> Never having used this SQL function before though i'm wondering what you all think about this... it seems to work with the problematic entries as well as the ok ones but is there anything I'm missing with the use of this function? I've committed it to trunk but will wait before pushing it into v2.0 branch to see what you all think...
> 
> Regards,
> 
> John Smith | Learning Technologist
> Room A251, Govan Mbeki Building | School of Health & Life Sciences | Glasgow Caledonian University
> Cowcaddens Road | Glasgow | G4 0BA
> 
> Glasgow Caledonian University is a registered Scottish charity, number SC021474
> 
> Winner: Times Higher Education’s Widening Participation Initiative of the Year 2009 and Herald Society’s Education Initiative of the Year 2009.
> http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
> 
> Winner: Times Higher Education’s Outstanding Support for Early Career Researchers of the Year 2010, GCU as a lead with Universities Scotland partners.
> http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,15691,en.html
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev



More information about the Xerte-dev mailing list