+ }
+ }
+ $mtc_obj = pg_fetch_object($mtc_pg,0);
+
+ /*
+ * games management
+ */
+ $gam_sql = sprintf("INSERT INTO %sbin5_games (mcode, tstamp)
+ VALUES (%d, to_timestamp(%d)) RETURNING *;",
+ $G_dbpfx, $mtc_obj->code, $date);
+ if ( ! (($gam_pg = pg_query($this->dbconn->db(), $gam_sql)) != FALSE &&
+ pg_affected_rows($gam_pg) == 1) ) {
+ log_crit(sprintf("bin5_points_save: failed at insert game [%s]", $gam_sql));
+ break;
+ }
+
+ $gam_obj = pg_fetch_object($gam_pg,0);
+
+ /*
+ * points management
+ */
+ for ($i = 0 ; $i < $n ; $i++) {
+ /* put points */
+ $pts_sql = sprintf("INSERT INTO %sbin5_points (gcode, ucode, pts)
+ VALUES (%d, %d, %d);",
+ $G_dbpfx, $gam_obj->code, $ucodes[$i], $pts[$i]);
+ if ( ! (($pts_pg = pg_query($this->dbconn->db(), $pts_sql)) != FALSE &&
+ pg_affected_rows($pts_pg) == 1) ) {
+ log_crit(sprintf("bin5_points_save: failed at insert point [%s]", $pts_sql));
+ break;
+ }