-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathSetCharset.php
50 lines (40 loc) · 1.38 KB
/
SetCharset.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once 'Generic.php';
/**
* Converter: mysql_set_charset.
*
* @category Functions
*
* @author Nokim <nokim@ukr.net>
* @license http://www.php.net/license/3_0.txt PHP License 3.0
*/
class MySQLConverterTool_Function_SetCharset extends MySQLConverterTool_Function_Generic
{
public $new_name = 'mysqli_set_charset';
public function __construct()
{
}
public function handle(array $params = array())
{
// bool mysql_select_db ( string database_name [, resource link_identifier] )
// mixed mysqli_query ( mysqli link, string query [, int resultmode] )
if (count($params) < 1 || count($params) > 2) {
return array(self::PARSE_ERROR_WRONG_PARAMS, null);
}
@list($charset, $conn) = $this->extractParamValues($params);
if (is_null($conn)) {
$conn = $this->ston_name;
}
list($charset, $charset_type) = $this->extractValueAndType(trim($charset));
if ('const' == $charset_type) {
$ret = sprintf('((bool)mysqli_set_charset(%s, constant(\'%s\')))', $conn, $charset);
} else {
$ret = sprintf('((bool)mysqli_set_charset(%s, "%s"))', $conn, $charset);
}
return array(null, $ret);
}
public function getConversionHint()
{
return 'Direct mapping to mysqli_set_charset with swapping parameters.';
}
}