2

I have a project made in flex, using PHP data services to access an 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:

$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[]

3

1 Answer 1

4

from the manual

Returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in resultset.

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.

Sign up to request clarification or add additional context in comments.

1 Comment

based on your response i found this stackoverflow.com/questions/6537212/… , thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.