$stmt = prepex(59, $db, 'SELECT id, label AS "label" FROM test WHERE label = ?', array('row1')); $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC); $exp = array(0 => array("id" => "1", "label" => "row1")); if (MySQLPDOTest::isPDOMySQLnd()) { // mysqlnd returns native types $exp[0]['id'] = 1; } if ($tmp !== $exp) { printf("[065] Results seem wrong. Please check dumps manually.\n"); var_dump($exp); var_dump($tmp); } $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = ?)", $db->quote('%ro%')); $stmt = prepex(60, $db, $sql, array(-1)); if (count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 0) { printf("[061] Expecting zero rows, got %d rows\n", $tmp); } $sql = sprintf("SELECT id, label FROM test WHERE (id = ?) OR (label LIKE %s)", $db->quote('%ro%')); $stmt = prepex(61, $db, $sql, array(1)); if (count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 2) { printf("[062] Expecting two rows, got %d rows\n", $tmp); } $sql = "SELECT id, label FROM test WHERE id = ? AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; $stmt = prepex(63, $db, $sql, array(1, 1)); if (count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 1) { printf("[064] Expecting one row, got %d rows\n", $tmp); } } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); } print "done!";
/* TODO enable after fix $stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)', array(':placeholder' => 'row'), array('execute' => array('sqlstate' => '42000', 'mysql' => 1064))); */ $stmt = prepex(78, $db, 'SELECT id, label AS "label" FROM test WHERE label = ?', array('row')); $sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = ?)", $db->quote('%ro%')); $stmt = prepex(79, $db, $sql, array(-1)); if (count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 0) { printf("[080] Expecting zero rows, got %d rows\n", $tmp); } $sql = sprintf("SELECT id, label FROM test WHERE (id = ?) OR (label LIKE %s)", $db->quote('%ro%')); $stmt = prepex(81, $db, $sql, array(1)); if (count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 2) { printf("[082] Expecting two rows, got %d rows\n", $tmp); } $sql = "SELECT id, label FROM test WHERE id = ? AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; $stmt = prepex(83, $db, $sql, array(1, 1)); if (count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 1) { printf("[084] Expecting one row, got %d rows\n", $tmp); } $sql = "SELECT id, label FROM test WHERE id = :placeholder AND label = (SELECT label AS 'SELECT' FROM test WHERE id = ?)"; $stmt = prepex(85, $db, $sql, array(1, 1), array('execute' => array('sqlstate' => 'HY093'))); if (is_object($stmt) && count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 0) { printf("[086] Expecting no rows, got %d rows\n", $tmp); } } catch (PDOException $e) { printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo())); } print "done!";