Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mysql-specific warning count function #13

Closed
Danack opened this issue Dec 15, 2022 · 1 comment
Closed

add mysql-specific warning count function #13

Danack opened this issue Dec 15, 2022 · 1 comment

Comments

@Danack
Copy link

Danack commented Dec 15, 2022

Description

https://github.com/php/php-src/pull/6677/files


Viewed
@@ -0,0 +1,22 @@
--TEST--
MySQL PDO->mysqlGetWarningCount()
--SKIPIF--
<?php
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
?>
--FILE--
<?php
	require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
	$db = MySQLPDOTest::factory();
	$assertWarnings = function ($db, $q, $count) {
		$db->query($q);
		printf("Query %s produced %d warnings\n", $q, $db->mysqlGetWarningCount());
	};
	$assertWarnings($db, 'SELECT 1 = 1', 0);
	$assertWarnings($db, 'SELECT 1 = "A"', 1);
?>
--EXPECT--
Query SELECT 1 = 1 produced 0 warnings
Query SELECT 1 = "A" produced 1 warnings



/* {{{ proto string PDO::mysqlGetWarningCount()
   Returns the number of SQL warnings during the execution of the last statement */
static PHP_METHOD(PDO, mysqlGetWarningCount)
{
	pdo_dbh_t *dbh;
	pdo_mysql_db_handle *H;

	dbh = Z_PDO_DBH_P(ZEND_THIS);
	PDO_CONSTRUCT_CHECK;

	H = (pdo_mysql_db_handle *)dbh->driver_data;
	RETURN_LONG(mysql_warning_count(H->server));
}
/* }}} */

static const zend_function_entry dbh_methods[] = {
	PHP_ME(PDO, mysqlGetWarningCount, NULL, ZEND_ACC_PUBLIC)
	PHP_FE_END
};

static const zend_function_entry *pdo_mysql_get_driver_methods(pdo_dbh_t *dbh, int kind)
{
	switch (kind) {
		case PDO_DBH_DRIVER_METHOD_KIND_DBH:
			return dbh_methods;
		default:
			return NULL;
	}
}

/* {{{ pdo_mysql_request_shutdown */
static void pdo_mysql_request_shutdown(pdo_dbh_t *dbh)
{
@@ -625,7 +655,7 @@ static const struct pdo_dbh_methods mysql_methods = {
	pdo_mysql_fetch_error_func,
	pdo_mysql_get_attribute,
	pdo_mysql_check_liveness,
	NULL,
	pdo_mysql_get_driver_methods,
	pdo_mysql_request_shutdown,
	pdo_mysql_in_transaction,
	NULL /* get_gc */

@Danack Danack mentioned this issue Mar 4, 2023
@Danack
Copy link
Author

Danack commented May 5, 2023

This is done.

@Danack Danack closed this as completed May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant