@@ -2203,4 +2203,35 @@ public function testStoredProcedureExecution() {
22032203 // Clean up
22042204 $ schema ->raw ("DROP PROCEDURE GetUserCount " )->execute ();
22052205 }
2206+
2207+ /**
2208+ * @test
2209+ */
2210+ public function testRawSelectWithParameters () {
2211+ $ schema = new MySQLTestSchema ();
2212+
2213+ $ schema ->raw ("CREATE TEMPORARY TABLE test_params (id INT, name VARCHAR(50), age INT) " )->execute ();
2214+ $ schema ->raw ("INSERT INTO test_params VALUES (1, 'John', 25), (2, 'Jane', 30), (3, 'Bob', 25) " )->execute ();
2215+
2216+ $ result = $ schema ->raw ("SELECT * FROM test_params WHERE age = ? " , [25 ])->execute ();
2217+ $ this ->assertEquals (2 , $ result ->getRowsCount ());
2218+
2219+ $ result = $ schema ->raw ("SELECT * FROM test_params WHERE name = ? AND age = ? " , ['John ' , 25 ])->execute ();
2220+ $ this ->assertEquals (1 , $ result ->getRowsCount ());
2221+ $ this ->assertEquals ('John ' , $ result ->getRows ()[0 ]['name ' ]);
2222+ }
2223+
2224+ /**
2225+ * @test
2226+ */
2227+ public function testRawInsertWithParameters () {
2228+ $ schema = new MySQLTestSchema ();
2229+
2230+ $ schema ->raw ("CREATE TEMPORARY TABLE test_insert (id INT, name VARCHAR(50), email VARCHAR(100)) " )->execute ();
2231+ $ schema ->raw ("INSERT INTO test_insert (id, name, email) VALUES (?, ?, ?) " , [1 , 'Alice ' , 'alice@test.com ' ])->execute ();
2232+
2233+ $ result = $ schema ->raw ("SELECT * FROM test_insert WHERE id = ? " , [1 ])->execute ();
2234+ $ this ->assertEquals (1 , $ result ->getRowsCount ());
2235+ $ this ->assertEquals ('Alice ' , $ result ->getRows ()[0 ]['name ' ]);
2236+ }
22062237}
0 commit comments