mysql

Should I create indexes on tinyint field types in mysql tables?

Hi I was just working on a web application and find that the most the mysql tables have fields, like, is_live, can_do, required, published (and many more) having field type TINYINT, and takes either 0 or 1 only. I was just wondering if I need to create indexes on these columns as scripts are using joins which include these columns as w...

How many weeks are inside of two dates.

I have starting dates and ending dates in my database (MySQL). How can I get the answer, how many weeks(or days) are inside of those 2 dates? (mysql or php) For example I have this kind of database: Started and | will_end 2009-12-17 | 2009-12-24 2009-12-12 | 2009-12-26 ... Update to the question: How to use DATEDIFF? How can I make ...

Sphinx requirements, would it work on my Webhostings provider ?

I am still searching for a search engine to be used on my webhosting-providers server (one.com) and still haven't found any. I have heard great things about Sphinx, what are the requirements to run it? I have read the manual, doesn't say much, seems like it should work... Just want to ask some professionals first. I dont have access t...

PDO: If my host ist localhost:80, what do I have to put in here?

I got this example from the php site: <?php try { $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass); foreach($dbh->query('SELECT * from FOO') as $row) { print_r($row); } $dbh = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?> I use MAMP on the m...

Problem installing mysql gem on Snow Leopard: uninitialized constant MysqlCompat::MysqlRes

Hi All I've got a problem trying to install the Ruby mysql gem driver. I recently upgraded to Snow Leopard and did the Hivelogic manual install of MySQL. This all seems to work fine as I can access mysql from the command line and make changes to the database. My problem is that if I now use rake db:migrate I get: rake aborted! uni...

Which Location Mysql complied Procedures Stored?

Hi, How can i get the Compiled Mysql stored procedures from Physical Location? ...

How to use DATEDIFF? How many days are inside of two dates.

How to use DATEDIFF? How can I make this to work? or should I use DATEDIFF completly differently? SELECT DATEDIFF('Started ','will_end') AS 'Duration' FROM my_table WHERE id = '110'; I try to get answer, how many days are inside of two dates. I would like to get an aswer like: Duration = 7 days; I have this kind of database: Start...

What ports should I be opening thru my firewall to access MySQL behind it

I currently have a web server in front of a firewall and my MySQL DB behind the firewall. I have already opened port 3306 for tcp, but still cannot connect thru the firewall. Any ideas? Thanking all in advance :) ...

Help with recursive SELECT

Here's the situation. I have two tables: users (registered users of the website), messages (personal messages they sent between each other) The messages table has these columns (just the important ones): id, sender (id of user who sent the message), receiver id of user to whom the message was sent), reply_to (id of a message to ...

The best way to display some statistical info on a site?

Hi I have a requirement to show three different types stats on the home page of a website. These are controlled/managed by an admin. For example, these are, type A items - 1200, type B items - 4500, blah items - 1800 I can just create a table, homepage_stats (id, first_field, second_field, third_field). Then on homepage SELECT fi...

How to Pass Variable inside DQL CodeIgniter

i got a question in DQL how to pass session User id $vars['mood'] = Doctrine_Query::create() ->select(’m.mood_name, a.id, m.account_id’) ->from(’mood m, m.account a’) ->where(’m.account_id=”7″‘) i want to show data according to current logged user. m.account_id=Current_User::user()->id; this is not working ...

How to read FoxPro Memo with PHP?

I have to convert .DBF and .FPT files from Visual FoxPro to MySQL. Right now my script works for .DBF files, it opens and reads them with dbase_open() and dbase_get_record_with_names() and then executes the MySQL INSERT commands. However, some fields of these .DBF files are of type MEMO and therefore stored in a separate files ending in...

Case Sensitivity and Indices in MYSQL

I am creating a system where is use e-mail address as unique identifier. There are times I need to look for a user by the e-mail address. If the user enters the e-mail address in all lower case, but the database has it stored as mixed case, is it a full scan, or will the database still use the index? This really is a problem because I ...

Combine many MySQL queries with logic into data file.

Background: I am parsing a 330 meg xml file into a DB (netflix catalog) using PHP script from the console. I can successfully add about 1,500 titles every 3 seconds until i addd the logic to add actors, genre and formats. These are separate tables linked by an associative table. right now I have to run many, many queries for each titl...

How many significant digits should I store in my database for a GPS coordinate?

I have in my MySQL database both longitude and latitude coordinates (GPS data). It's currently stored as: column type ------------------------ geolat decimal(10,6) geolng decimal(10,6) Question: Do I really need a data type as large as decimal(10,6) to properly store coordinate data? Since I have a combined index on the...

Select trims spaces from strings - is this a bug or in the spec?

in mysql: select 'a' = 'a '; return 1 ...

PHP echo duplicate rows when none exist

<html> <head> <title>Test</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <?php $username ="matt"; $pass = "bs12kfj"; $db = "mytest"; $tbl = "test2"; mysql_connect(localhost,$username,$pass); mysql_select_db($db) or die( "Unable to select database"); $res = mysql_query("SELEC...

Does Python support MySQL prepared statements?

I worked on a PHP project earlier where prepared statements made the SELECT queries 20% faster. I'm wondering if it works on Python? I can't seem to find anything that specifically says it does or does NOT. ...

Unload images from MySQL to disk.

I have images stored in MySQL as blobs (i know it's wrong). And there are many of them. Is there any fast way to drop them all on disk, like SELECT .. INTO OUTFILE, but to many files insted of one? Or the only way is writing a script that will iterate over rows and save images? ...

Trigger before delete MySql

I have a table named user. This table has a foreign key to a department table. One user can be associated with one department. Before deleting a department, I would like to set any user (having that department ID) to a default value (1) to avoid a referential integrity error. Do you know a good example. Most examples shows that the trig...