mysql

What data type would I use if I want to save a file from a user using PHP and MySQL?

I want users to be able to upload their CV in PDF, .txt, .doc, .docx; and allow potential employers to download the file. What data type should I use? In MS MSQL, I would use varbinary(max), right? But since I'm new to MySQL I'm a bit confused. :) ...

How to remove empty tables from a MySQL backup file.

I have multiple large MySQL backup files all from different DBs and having different schemas. I want to load the backups into our EDW but I don't want to load the empty tables. Right now I'm cutting out the empty tables using AWK on the backup files, but I'm wondering if there's a better way to do this. If anyone is interested, this i...

Need a little feedback about my database design, pretty straightforward.

I'm going to allow companies to register on my website and create job listings. I'm currently approaching the problem by creating a Company table with Name, Logo and Password fields. Then when a person registers he can say, "I belong to X company"; at this point, I'll request the password written in by the initial registrator. If she/he...

Wordpress loop: Grouping by category?

Hello, I need to get all posts via the wordpress loop but i need them to be grouped by category and cronological within each category. Anyone know how I should go about this? Thanks! ...

Using SELECT with a primary key in MySQL

I'm trying to speed up my SELECT queries in my web application. I have done some pretty major optimizations, like ordering the rows returned by PHP rather than MySQL itself. Now I'm just wondering, is it faster to use the SELECT statement on columns that are a primary key? Example, I have a table set up with the columns settingKey and s...

Mysql: enum confusion

I have an employee table, employee has interests, so the table can be designed like this: create table emp( id int(10) not null auto_increment, name varchar(30), interest varchar(50), primary key(id) ); or this: create table emp( id int(10) not null auto_increment, name varchar(30), interest enum('football','basketball','music...

PHP/MySQL group results by column

Hello, in order to keep as few SQL statements as possible, I want to do select set from MySQL: SELECT * FROM products WHERE category IN (10,120,150,500) ORDER BY category,id; Now, I have list of products in following manner: CATEGORY - product 1 - product 2 CATEGORY 2 - product 37 ... What's the best and most efficent way to pr...

MySQL - Order by number of chars

I have the most simple SQL SELECT * FROM words It has 13000 words (varchar). I need to get the longest word first in my output. I guess it might be possible with the WHERE command? Alternative If it doesn't work like that, is there a smart way to sort my output array so it will order it by the longest word first (in the 'word'-colum...

In MySQL, how to copy the content of one table to another table within the same database?

I new to MySQL. I would like to copy the content of one table to another table within the same database. Basically, I would like to insert to a table from another table. Is there easy way of doing this? thanks for any help ...

Access denied for user 'speedycm_root'@'localhost' to database 'speedycms'

been trying to set up a webserver with uk2.net all day but i keep receiving the following error when i try to log in: Access denied for user 'speedycm_root'@'localhost' to database 'speedycms' what could it mean? <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_speedycms = "localhost"; $database_spee...

saving mySql row checkpoint in table ?

hello, I am having a wee problem, and I am sure there is a more convenient/simpler way to achieve the solution, but all searches are throw in up a blanks at the moment ! I have a mysql db that is regularly updated by php page [ via a cron job ] this adds or deletes entries as appropriate. My issue is that I also need to check if any...

What is the least expensive method to get a row count for a SQL Query?

When writing a query for paging on a web page what is the least expensive method to get a total row count? Is there a way to do this without running a query twice - one for the total and the next for the limit? Using MySQL Example: (I want to know if there is a less expensive way) Get Count SELECT COUNT(*) FROM table Get Paging SE...

UTF-8: General? Bin? Unicode?

I'm trying to figure out what collation I should be using for various types of data. 100% of the content I will be storing is user-submitted. My understanding is that I should be using UTF-8 General CI (Case-Insensitive) instead of UTF-8 Binary. However, I can't find a clear a distinction between UTF-8 General CI and UTF-8 Unicode CI. ...

Appropriate character encoding / collation to store URLs?

My web application stores URL segments in a database. These URL segments are based on user-submitted content. What collation should I use for character strings that will appear in URLs? My assumption is ASCII General CI (?) based on this question: http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid ...

How do you get the last access (and/or write) time of a MySQL database?

How do you find out the last time a MySQL database was read or written to? Can you even do that check per table? ...

MySQL Corruption After Graceful Restart

Has anyone ever encountered MySQL corruption after performing a graceful server reboot? Just worries me because I have never had that happen before. What could be the causes? ...

MySQL Design for Handling Products with Custom Fields

I'm building an web application where an product can be of a few different types (furniture types, actually) and depending upon those types, the product has certain fields associated with it. Quick Background: I'm using MySQL and PHP with CakePHP as my framework. The answer I'm looking for doesn't necessarily need to be "CakePHP-like"; ...

How can I store HTML color codes in a MySQL database then search for a range or colors?

I have a script that extracts the mostly commonly occurring colors from an image. I want to store this data in MySQL then be able to pull out images based on the clicking of a color. For example if the user clicks on a red color I want to pull out other images that have a high count for "red" colors. I'm not sure how to search within a r...

How do I make my database connection secure?

I'm currently working on a website for my church's college group, and am started to get a little worried about the security of what I'm writing. For instance, I use this function: function dbConnect() { global $dbcon; $dbInfo['server'] = "localhost"; $dbInfo['database'] = "users"; $dbInfo['username'] = "root"; $dbInfo['pas...

SQL query to pull multiple entries with same user_id

I have a table that contains id, created, user_id. I'm wondering if there is a query that'll return all unique user_ids that have more than one entried created within the last week. I started with: $query = "SELECT distinct user_id FROM task where created >= '" . date("Y-m-d", strtotime("-1 week", strtotime($date))) . " 00:00:00' and c...