mysql

ActiveRecord::StatementInvalid: Mysql::Error:

I tried to google hardcore to get what creates this problem, but nothing helped me, so i'm triing to write here! while doing: User.create(:name => "daniel") or User.new(:name => 'daniel').save in the rails console, i get this error ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '5' for key 1: INSERT INTO users (name, s...

How do I make MySQL's NOW() and CURDATE() functions use UTC?

I want to make it so calls to NOW() and CURDATE() in MySQL queries return the date in UTC. How do I make this happen without going through and changing all queries that use these functions? Believe, me, I have been Googling for the answer, but in 20 minutes, I have found nothing that has worked. ...

php/mysql: database of bank holidays and events like christmas, easter etc...

Hi guys, Im working on a simple calendar application and i want to have the above events display on the calendar [bank holidays and that]. The calendar is just a standard month view, with a link to view each day for each day in the month, and links to view next/ previous month and year etc... i will probably have the mktime for each e...

Lists and MySQL queries

Would it be possible to run a MySQL query pulling the names of locations from a table, inserting them into a dropdown menu and then automatically generating a URL for each one e.g. blablabla.bla/index.php?location=blablabla every time the page loads? Any help is appreciated. ...

How to best store user information and user login and password

I'm using Mysql and I was assuming it was better to separate out a users personal information and their login and password into two different tables and then just reference them between the two. Note : To clarify my post, I understand the techniques of securing the password (hash, salt, etc). I just know that if I'm following practices ...

iPhone: Connecting to database over Internet ?

I've been talking with someone about the possibility of a iPhone development contract gig. All I really know at this point is that there is a company that wants to make an iPhone app that will hit their internal database. I'm not sure what the database type is( Oracle, MySQL, etc...). I've wanted to know if the database type was Oracle...

how to sort query result in php?

Hi, I am trying to sort query result into an array. I have following query. "select s.*, a.* from students left join addresses as a"; it returns s.id s.name a.id a.student_id a.address I would like to make above result into an array with s and a keys. array( "s"=>array("id"=>"value","name"=>"value") ,"a"=>array("id"=>"value...

How To Sort Like Hacker News

I am trying to program a plugin to bbPress (the open source forum software) that will work similar to Hacker News (http://news.ycombinator.com/). Specifically, I want to sort the order of forum-threads (bbPress calls them "topics") using the following algorithm: sort_value = (p - 1) / (t + 2)^1.5 where p = total votes for each topic fr...

How can I process data to avoid MySQL "incorrect string value" error?

I am trying to use a Rake task to migrate some legacy data from MS Access to MySQL. I'm working on Windows XP, using Ruby 1.8.6. I have the encoding for Rails set as "utf8" in database.yml. Also, the default character set for MySQL is utf8. 99% of the data is coming in fine, but every now and then I'll get a column value that gives me...

MySQL connection in ASP.NET references Issue

I have some code written that is attempting to connect to a mysql db. I have installed this. I have added a reference which is MySql.Data.CF.dll in the project. The project compiles with no complaints. When I execute this... string conn_str = ConfigurationManager.ConnectionStrings["MySQLServer"].ConnectionString; DataSet m_Dst = new Da...

How do I convert from BLOB to TEXT in Mysql?

Hiya, I have a whole lot of records where text has been stored in a blob in MYSQL. For ease of handling I'd like to change the format in the DB to TEXT .. any ideas how easily to make the change so as not to interrupt the data - I guess it will need to be encoded properly? ...

Carrying row values from MYSQL after form submission.

What is the best way to carry an auto incremented ID from one form to another? I have 3 tables (users, residences, and users_residences). I want a user to register, be added to the users table, be redirected to a form to create a residence which will add a row to the residence table and simultaneously add the the residence tabe row's i...

Subsonic 2.2 + MySql 5 + StoredProcs = 'SPs' is not a member of 'SubSonic'?

Hey All, I have been using SS2.1 for quite a while now and have been loving it. However, I noticed that 2.2 was out so I thought it would be best to upgrade. After dropping 2.2 into my bin folder, it no longer builds the stored procedures from MySQL that were working so perfectly with v2.1. What happened? What am I missing here? On...

distinct or group?which is more efficient in mysql?

Here is my trial: mysql> select a.id from iask a -> join ianswer b on a.id=b.iaskid -> join users c on c.id=a.uid -> where (c.last_check is null or a.created>c.last_check) and c.id=1 -> group by a.id; +----...

master-slave design problem

By design,all read should be from slave,and update on master, but consider the following situation: there is a column water_mark in table_a, and I need to read from table_b whose column time_mark is larger than column water_mark of table_a, If I read from slave,then update the column water_mark to "now()" in master, what if there ...

[Mysql] Is there a way to prevent duplicate entries in a table pivot/mapping?

I'm relatively new to MySQL, and I was wondering if it was possible to prevent duplicate entries in a table pivot/mapping which has no primary key and a many-to-many relationship. A simple example: table 1 table1ID field field table 2 table2ID field field pivot table table1ID table2ID Since a many-to-many relationship would mean tha...

MySQL Get All Except If

I have a MySQL table and I want to extract all rows except if the column contains a specific value. Is this possible? My table structure +----+------+------+------+ | ID | col1 | col2 | col3 | +----+------+------+------+ | 1 | blah | blah | boo | +----+------+------+------+ | 2 | blah | blah | blah | +----+------+------+------+ | 3...

Best way to update user rankings without killing the server

I have a website that has user ranking as a central part, but the user count has grown to over 50,000 and it is putting a strain on the server to loop through all of those to update the rank every 5 minutes. Is there a better method that can be used to easily update the ranks at least every 5 minutes? It doesn't have to be with php, it...

PHP equivalent to MySQL's slow query log?

I am working on optimizing my site, and I have had the MySQL slow queries log on for a few days now, but after going through >260M queries, it only logged 6 slow queries, and those were special ones executed by me on phpMyAdmin. I am wondering if there is something to log slow PHP page execution time so that I can find certain pages tha...

Bad idea to have two unique IDs in database table?

Hello all, I wish to allow users to be able to view records from my database by following a URL. I am guessing its not a good idea to have this sort of URL where the identifier of the record to be viewed is the record auto increment ID! http://www.example.com/$db_record_id The above is giving info away unnecessarily. Is this reall...