mysql

Disadvantages of storing images in a Database?

Hey! Can anyone please tell me the disadvantages of storing images in a MySQL database? Is it not as efficient as storing the images on the server? Like, will it take longer for the images to load and perhaps slow download the database? Appreciate the help! ...

SQL database views

Hello all, I have just created a db with 8 tables that each have over 1000000 rows(data collected for every second over the summer :S) I am planning on creating views so that a week can be selected at a time. I was wondering does it go against any unwritten db rules to create several databases that just contain views (one for each wee...

MySQL select of select ?

Hi all, I'm having problems with a sql query, here's an generalization of what I'm trying to do: select oh.a as a, oh.b as b, oi.c as c, (select h.d from history h where h.id = oh.id and h.d not in ('d1', 'd2') order by h.date limit 1) as d from order_header oh join order_item oi on oh.order_id = oi.order_id where oh.state in (0,...

Safe alternative to mysql_real_escape_string? (PHP)

I am passing a variable to a function that executes a query The MySQL connection only occurs inside the function, and closes inside the function I want to be able to safely escape strings BEFORE I send them to the function I can't use mysql_real_escape_string because it requires a MySQL connection (which is only being made inside the ...

MySQL 3 table join

I have data to get listings according to their location. The locations are mapped in a location map table. The structure basically looks like: listings -id -title etc. locations -id -location_name etc. location_map -listing_id -location_id When I want to list the listings according to their location, I am using th...

Unix socket connection to MySql with Java to avoid JDBC's TCP/IP overhead?

Is it possible to make a Unix socket connection to MySql with Java to avoid JDBC's TCP/IP overhead? Does anyone know a library (or a few libraries, perhaps) that makes this possible? ...

Find is a business is open: MySQL hours calculation.

I have a list of business stored in a locations table, and stored in that table are hours the business opens and closes: location `mon_1_open` `mon_1_closed` `tue_1_open` `tue_1_closed` `wed_1_open` `wed_1_closed` ect... I store the times in full hours and minutes, so say a business is open from 9:00AM to 5:30PM on monday.. mon_1_ope...

Mysql - Simple select query returns dublicate values?

The title says it all. This is how the query looks like: (simplified) SELECT * FROM posts WHERE user='37' ORDER BY date DESC I currently only ave one row in that table, but still for some reason it returns two rows that are exactly the same. At first i thought i messed up with the loop, but i tried printing the returned array out with...

PHP/MySQL Deleting images

Hi, this is following on from this question I posted yesterday - my question from yesterday The answer given by webbiedave seemed to work but continued to delete the last image in the group rather than the one selected through the checkbox. When I print_r($_POST); none of these images can be found anywhere in the printed array. Within t...

MySQL: index on non-primary key column

is it possible to use a column other than the primary key as the index and are there any disadvantages to doing that? ...

Convert MySQL tinyint types to bit

I used the MySQL Migration Toolkit to migrate a SQL Server 2008 database to MySQL. However, it converted all my bit types to tinyint. My data model doesn't like this, because I have a bunch of expressions testing for true/false, and not 0-255. Is there a way to tell the Toolkit to convert these different, or some SQL I can run on the ne...

CakePHP Find - Order By String-To-Int?

I want to use CakePHP to pull an array of photos from a database, sorted by photo title (0, 1, 2, 3...) My query currently looks something like: $ss_photos = $this->Asset->find('all',array( 'conditions'=>array('kind'=>'photo'), 'order'=>'title' )); Unfortunately the titles seem to be in string format, leading to an undesirable s...

InnoDB Plugin Version command?

Is there any way to make MySQL tell you what version of the InnoDB plugin it's running? I know you can look at the documentation, but I'm trying to verify a potential bug if the plugin jives with the mysql version installed. mysql> show variables like '%version%'; +-------------------------+------------------------------+ | Variable_nam...

MySQL group by issue

I'm having a strange problem with MySQL and would like to see if the community has any thoughts: I have a table 'tbl' that contains ____________ | id | sdate | And I'm trying to execute this query: select id, max(sdate) as sd from tbl where id in(123) group by id; This returns no results. However, this query: select id, sdate...

sql queries and inserts

I have a random question. If I were to do a sql select and while the sql server was querying my request someone else does a insert statement... could that data that was inputted in that insert statement also be retrieved from my select statement? ...

Log out everywhere, where else I am logged in

I currently use PHP sessions as the basis of my user login system, with a successful login setting $_SESSION['userid']. This allows a user to log in to the same account from multiple machines. However, I'd like to implement the following features: Log out everywhere, similar to what Stack Overflow has. See where else one is logged in....

PHP framework or library for DB abstraction, secure login

I am building a site that requires a lot of MySQL inserts and lookups from different tables in a (hopefully) secure part of the site. I want to use an abstraction layer for the whole process. Should I use a PHP framework (like Zend or CakePHP) for this, or just use a simple library (like Crystal or Doctrine)? I would also like to make s...

How do you create a ADO.NET Entity Data Model for a MySQL database using Visual Web Express 2010?

Can I create a ADO.Net Entity Data Model for a MySql(5.0.1) Database using a Visual Web Express 2010? If yes, can anyone please let me know how to do this. Thanks. ...

mysql_num_rows always returns 1

The result is always 1: $sql = 'SELECT COUNT(Vote) FROM ' . $table; $res = mysql_query($sql, $conn); $vote_total = mysql_num_rows($res); I ran the $sql query in phpMyAdmin and it returns 3, so the query is not the problem. $vote_total is initialized globally to 0, so that 1 is coming from somewhere. What other information do I need to...

How do I return true or false if multiple columns equal a certain value in MySQL query?

I have a single DB table (MySQL) which I am running a simple SELECT on. In this table I have 3 fields which contain 3 possible values each. In each case the values are identical ('none','online','physical'). I want to return in my result a true or false value for an alias if any one of these fields are not set to 'none'. I can easily ev...