i have a project made in flex, using php data services to access a sql server database, and i need to convert it to mysql, i have changed all my php services from sqlsrv to mysqli.
Something like this:
我有一个flex项目,使用php数据服务访问sql server数据库,我需要将它转换为mysql,我已经将我所有的php服务从sqlsrv更改为mysqli。像这样的东西:
$this->connection = mysqli_connect(SERVER,USERNAME,PASSWORD,DATABASE); // Start Connection
$ssqlstring = "select * from Users";
$runssql = mysqli_query($this->connection, $ssqlstring);
while($user = mysqli_fetch_array($runssql))
{
$users[$user["ID"]] = $user;
}
return $users;
it worked fine on sqlsrv but with mysqli it returns to flex the INT
, BIT
or DATE
values as string
the main Datatypes on mysql are INT
,VARCHAR
,BIT(1)
,DATETIME
,DATE
(same as sqlsrv)
and on the flex the return types are mainly as object[]
它在sqlsrv上工作得很好,但是使用mysqli它返回弹性INT,BIT或DATE值作为字符串mysql上的主数据类型是INT,VARCHAR,BIT(1),DATETIME,DATE(与sqlsrv相同)和flex返回类型主要是作为对象[]
1 个解决方案
#1
3
从手册
Returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in resultset.
返回与获取的行对应的字符串数组,如果resultset中没有更多行,则返回NULL。
There are relatively few native types in PHP, in short, possibles are INT, FLOAT and STRING (where STRING is the default for all the rest, like BIT and DATE etc.). PDO
is a bit better at using more close-to-actual types, but still defaults to strings a lot. In mysqli
, you could use mysqli_result_fetch_fields
to get the type of field returned, and cast it to a desired format, see also the MYSQLI_TYPE_*
constants.
PHP中的本机类型相对较少,简而言之,可能是INT,FLOAT和STRING(其中STRING是所有其他类型的默认值,如BIT和DATE等)。 PDO在使用更接近实际的类型方面要好一些,但仍然默认为字符串很多。在mysqli中,您可以使用mysqli_result_fetch_fields来获取返回的字段类型,并将其转换为所需的格式,另请参阅MYSQLI_TYPE_ *常量。
#1
3
从手册
Returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in resultset.
返回与获取的行对应的字符串数组,如果resultset中没有更多行,则返回NULL。
There are relatively few native types in PHP, in short, possibles are INT, FLOAT and STRING (where STRING is the default for all the rest, like BIT and DATE etc.). PDO
is a bit better at using more close-to-actual types, but still defaults to strings a lot. In mysqli
, you could use mysqli_result_fetch_fields
to get the type of field returned, and cast it to a desired format, see also the MYSQLI_TYPE_*
constants.
PHP中的本机类型相对较少,简而言之,可能是INT,FLOAT和STRING(其中STRING是所有其他类型的默认值,如BIT和DATE等)。 PDO在使用更接近实际的类型方面要好一些,但仍然默认为字符串很多。在mysqli中,您可以使用mysqli_result_fetch_fields来获取返回的字段类型,并将其转换为所需的格式,另请参阅MYSQLI_TYPE_ *常量。