tafazzi87
tafazzi87

Reputation: 69

information about a database sql version

i've a question...i want to use a mysql database and connect it to my android app, i wish to connect it and copy on sdcard and so every time that app starts i want to check version of mysql database. how can i check version of mysql database? i can't find anything about this... i connect to database by a php script like this:

<?php
//Connect to database and select it
mysql_connect("127.0.0.1","root","");
mysql_select_db("database");
//query
$sql=mysql_query("SELECT * FROM table");
//put all into an output
while($row=mysql_fetch_assoc($sql))
    $output[]=$row;
//print json object
print(json_encode($output));
//close database
mysql_close;
?>

Upvotes: 0

Views: 345

Answers (5)

sqlab
sqlab

Reputation: 6436

then there are e.g. two ways
1, compare the timestamp of the file on your sdcard with the timestamp of your db or

2, use a table with just one field and one row, where you store a version number of the last update/insert/delete and compare this.

If it's different, delete your old file on the sdcard and write a new with the name of your version –

Upvotes: 1

Aravind Kishore
Aravind Kishore

Reputation: 67

Try this.

while($row=mysql_fetch_assoc($sql))
$output[]=$row;
.
.
$ver = mysql_query('SELECT VERSION()');

$version=mysql_fetch_assoc($ver);
$output[]=$version;
.
.

print(json_encode($output));

If you want to get result from the same mysql server every time, just select version one time store it in the session or cookie and encode that value into json format.

Upvotes: 0

Surabhil Sergy
Surabhil Sergy

Reputation: 2006

Just need to try SELECT VERSION();

For more details on DB,

SHOW VARIABLES LIKE "%version%";

Duplicate of How to retrieve the current version of a MySQL database?

Upvotes: 1

Ryan
Ryan

Reputation: 3582

Pretty simple.

SELECT VERSION();

Output (in my case):

+------------+
| VERSION()  |
+------------+
| 5.1.69-log |
+------------+

Upvotes: 1

웃웃웃웃웃
웃웃웃웃웃

Reputation: 11984

You can try this query

SELECT VERSION();

Also you can check this for reference

Upvotes: 2

Related Questions