Paste: db-context dbfunc

Author: refaktor
Mode: rebol
Date: Wed, 6 Jul 2011 21:53:57
Plain Text |
sk-back: make db-context [
	
	charge: context [

		create: dbfunc [
			project: required calculate ( get-project-by-name current )
		] [
			insert into charge (id_project . date_time) values (#project . datetime("now")) 
		]
		
		clear-all: dbfunc [ ] [ delete from charge ]

		list: dbfunc [ ] [ select * from charge ]
	]

	work: context [
		
		start: dbfunc [
			project: required calculate ( get-project-by-name current )
		] [
			insert into work 
				(id_project . started . stopped) 
				values (#project . datetime("now") . null ) 
		]

		stop: dbfunc [] [
			update work 
				set stopped = datetime("now") 
				where id = (select max(id) from work) 
		]	

		did: dbfunc/verbose [
			project: required calculate ( get-project-by-name current )
			time: required calculate ( probe rejoin [ "-" current " hour" ] )
		] [
			insert into work 
				(id_project . started . stopped) 
				values ( #project . datetime("now" .  #time) . datetime("now") ) 
		]

	]
]

New Annotation

Summary:
Author:
Mode:
Body: