f1 = $f1; $this->f2 = $f2; } } function getConnection() { $con = mysqli_connect('localhost', 'root', '', 'test'); return $con; } function selectAllT1() { $con = getConnection(); $stmt = mysqli_prepare($con, 'SELECT f1,f2 FROM t1'); mysqli_stmt_execute($stmt); $rs = mysqli_stmt_get_result($stmt); $res = array(); while($row = mysqli_fetch_array($rs, MYSQLI_ASSOC)) { $f1 = $row['f1']; $f2 = $row['f2']; $res[] = new T1($f1, $f2); } mysqli_stmt_close($stmt); mysqli_close($con); return $res; } function insertOneT1($o) { $con = getConnection(); $stmt = mysqli_prepare($con, 'INSERT INTO t1 VALUES(?,?)'); mysqli_stmt_bind_param($stmt, 'is', $o->f1, $o->f2); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); mysqli_close($con); } function deleteOneT1($f1) { $con = getConnection(); $stmt = mysqli_prepare($con, 'DELETE FROM t1 WHERE f1 = ?'); mysqli_stmt_bind_param($stmt, 'i', $f1); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); mysqli_close($con); } ?>