Skip to content

Update ext/odbc parameter names #6303

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

Closed
wants to merge 5 commits into from
Closed

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 8, 2020

Some general notes:

  • odbc link (persistent) resource parameters are now $odbc, which appears to be the general convention
  • odbc result resource parameters are now $stmt. That is likely super controversial, because the method names contain "result" as well, but in ODBC parlance these are actually "statement"/"stmt", and "result" is misleading, since odbc_prepare returns a prepared statement, and not a result (set).
  • very unclear: the nomenclature of "field"/"column". These are pretty mixed regarding the parameter names, but the function names use "column" only for meta information, and "field" for actual column values. Not sure if that distinction makes sense regarding the parameter names.

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat connected with #6294 and probably @kocsismate will have similar questions ... in particular whether it should be $stmt or $statement :)

very unclear: the nomenclature of "field"/"column". These are pretty mixed regarding the parameter names, but the function names use "column" only for meta information, and "field" for actual column values. Not sure if that distinction makes sense regarding the parameter names.

I ended up using $field for everything in pgsql, as nearly all APIs had "field" in the name (only one mention of "column"). So I would probably do the same here and stick the terminology this DB driver seems to favor.

/** @param resource $result_id */
function odbc_free_result($result_id): bool {}
/** @param resource $stmt */
function odbc_free_result($stmt): bool {}

/** @return resource|false */
function odbc_connect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function odbc_connect(string $dsn, string $user, string $password, int $cursor_option = SQL_CUR_USE_DRIVER) {}
function odbc_connect(string $dsn, string $user, string $password, int $cursor_type = SQL_CUR_USE_DRIVER) {}

More in line with $fetch_type above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$cursor_type appears to be misleading; this is not about SQL_CURSOR_FORWARD_ONLY, SQL_CURSOR_KEYSET_DRIVEN, SQL_CURSOR_DYNAMIC or SQL_CURSOR_STATIC, but rather whether the ODBC cursor library (a compat layer for minimal drivers, which is deprecated at least on Windows) should be used. I don't have a better idea, so would be okay with $cursor_type).

@cmb69
Copy link
Member Author

cmb69 commented Oct 12, 2020

I have no strong opinion on $stmt vs. $statement. I'll take whatever will be decided.

Sticking with $field for odbc_result() makes sense. I'm gonna change that.

@cmb69 cmb69 changed the base branch from master to PHP-8.0 October 13, 2020 10:09
@nikic nikic mentioned this pull request Oct 13, 2020
Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only have one note, otherwise this looks good to me. @kocsismate ?

/** @param resource $result_id */
function odbc_field_name($result_id, int $field_number): string|false {}
/** @param resource $statement */
function odbc_field_name($statement, int $field_number): string|false {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elsewhere we do not make a distinction between $field_number and $field_name and just use $field (or $column depending on DB) for both. Whether it's a number or a name (a lot of APIs also accept both) is determined by the type.

(If we want to keep the distinction here, we should $field_number -> $field_num to keep the abbreviation consistent.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure here. Only odbc_field_num() accepts a name; all other odbc_field_*() functions expect the number (which looks strange to me). (ah, odbc_result() accepts either) But since we have the type, just $field looks good to me.

@php-pulls php-pulls closed this in 8e531b5 Oct 13, 2020
@cmb69 cmb69 deleted the cmb/odbc-params branch November 16, 2020 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants