Comparison

util/sql.lua @ 6758:88b89facc3c9

util.sql: Allow onconnect callback to fail connection to the DB by returning false, err
author Matthew Wild <mwild1@gmail.com>
date Tue, 07 Jul 2015 17:43:14 +0100
parent 6748:ccf4fcfc2024
child 6759:fb952032f83e
comparison
equal deleted inserted replaced
6757:fc9c1a566a19 6758:88b89facc3c9
109 if not dbh then return nil, err; end 109 if not dbh then return nil, err; end
110 dbh:autocommit(false); -- don't commit automatically 110 dbh:autocommit(false); -- don't commit automatically
111 self.conn = dbh; 111 self.conn = dbh;
112 self.prepared = {}; 112 self.prepared = {};
113 self:set_encoding(); 113 self:set_encoding();
114 self:onconnect(); 114 local ok, err = self:onconnect();
115 if ok == false then
116 return ok, err;
117 end
115 return true; 118 return true;
116 end 119 end
117 function engine:onconnect() 120 function engine:onconnect()
118 -- Override from create_engine() 121 -- Override from create_engine()
119 end 122 end