philip / MySQLConverterTool

A MySQL Converter Tool
314 stars 144 forks source link

What is the use of ___mysqli_ston #2

Open catalinux opened 10 years ago

catalinux commented 10 years ago

When converting I get all kind of GLOBAL keys of ___mysqli_ston.

I have a mysql_ wrapper class, so for two different objects I need link connection different

onkelfried commented 10 years ago

you have different connections, but you MUST use them directly. this global will in use if you have function calls without specifying connection link.

For example:

$link1 = mysql_connect(...); $link2 = mysql_connect(...);

$res1 = mysql_query($sql, $link1) or die( mysql_error($link1) ); $res2 = mysql_query($sql, $link2) or die( mysql_error($link2) );

will not cause problem, but something like this

$res1 = mysql_query($sql, $link1) or die( mysql_error() ); $res2 = mysql_query($sql, $link2) or die( mysql_error() );

will cause problems with mysql_error call, because both of them in waiting its own link and $link2 will given via globals after convert.

so use correct links and no problems, or do some patch =)

philip commented 8 years ago

@onkelfried addressed this well, but as for the strange name, perhaps one day we'll make this an option but for now you can edit the code to change the name (if you wish):

  1. Open Function/Generic.php
  2. Find this code: public $ston_name = '$GLOBALS["___mysqli_ston"]';
  3. Define $ston_name as something else, such as '$conn'.

But overall, it's difficult to make guesses here because ext/mysql and ext/mysqli are so different in this regard, so I suspect work around this issue will always require manual intervention.