jQuery-File-Upload icon indicating copy to clipboard operation
jQuery-File-Upload copied to clipboard

Working with databases UPDATE

Open exegeses opened this issue 13 years ago • 6 comments

Due to the fact that the mysql_connect extension is deprecated as of PHP 5.5.0, and will be removed in the future ref: http://www.php.net/manual/en/function.mysql-connect.php

here is an update using the MySQLi extension:

function query($query) {
$database = $this->options['database'];
$host = $this->options['host'];
$username = $this->options['username'];
$password = $this->options['password'];
$link = mysqli_connect($host,$username,$password, $database);
if (!$link) {
die(mysqli_error());
} $result = mysqli_query($query);
mysqli_close($link);
return $result;
}

that's it, simple and neat ;)

exegeses avatar Sep 12 '13 17:09 exegeses

The "Working with databases is a user contribution and not maintained by me. The wiki is user editable, so if you like, you can either update an existing article or add a new one. Thanks!

blueimp avatar Sep 12 '13 17:09 blueimp

I've added a sample as official doc: https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration

blueimp avatar Sep 12 '13 17:09 blueimp

I do not mind to hold credit, but a simple mention would be nice. ;)

greetz

2013/9/12 Sebastian Tschan [email protected]

I've added a sample as official doc:

https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration

— Reply to this email directly or view it on GitHubhttps://github.com/blueimp/jQuery-File-Upload/issues/2587#issuecomment-24340267 .

exegeses avatar Sep 12 '13 21:09 exegeses

I always give credit where credit is due, but I didn't use any of your code. First, the code I pasted into the new doc was taken from a customization project which I implemented last week. Second, your code uses the procedural style, while the code I used makes use of the object-oriented interface. See also: http://mx2.php.net/manual/en/mysqli.quickstart.dual-interface.php

blueimp avatar Sep 12 '13 21:09 blueimp

I think database is a good way to save additional properties,also convenient for search.But a question,If you use databae store file information,I think when load download files("get" method), no need to scandir first and then get additional properties from database,just get all the properties from database at one time,how do you think @blueimp

leapit avatar Dec 04 '13 03:12 leapit

Yeah, certainly. The version found in the wiki is just a sample and I've deliberately kept it close to the original files. Since the Wiki is used editable, feel free to improve on it, as long as you keep the object oriented style and don't introduce any security issues.

blueimp avatar Dec 04 '13 08:12 blueimp