mysql

Hibernate Encryption of Database Completely Transparent to Application

I'm working on a Grails 1.0.4 project that has to be released in less than 2 weeks, and the customer just came up with a requirement that all data in the database should be encrypted. Since encryption of every database access in the application itself could take a lot of time and will be error prone, the solution I seek is some kind of ...

Default values for COUNT in MySQL

I have a table looking something like this: +-------+-----+ |country|prop1| +-------+-----+ |RO | 1 | |RO | 2 | |UK | 1 | |IT | 2 | +-------+-----+ I want to count the rows for which the prop1 is not null and I use the following select: SELECT `country`, COUNT(*) as number FROM table GROUP BY `country`; this...

row(s) affected in mysql update with PHP

How do i find if my update is successful or not? i update using a where uniqueName=name so i should always only update 0 rows or 1. What is a good way to check if i updated a row or not? ...

Mysql mapping table FK constraints

Hi, I'm experiencing some difficulties with foreign key constraints. I have three tables: Features ID PK AUTO_INC Title VARCHAR Subscriptions ID PK AUTO_INC Title VARCHAR Subscriptionfeatures ID PK AUTO_INC feature_id INT (index) subscription_id INT (index) When I have the following records Features 1...

PHP; use sessions or re-use query?

Hey, I'm interested in what is the more efficient way of handling user data in my game. When someone is playing the game, data from the server will constantly need to be queried from the database. So I want to know if it is more efficient to keep querying the database or to store the data from the first query in a session and then keep...

PHP MySQL INSERT return value with one query execution

Is there anything returned from MySQL/PHP on a INSERT query being executed? Here is my function which I have in a CLASS. function mysqlQuery($query) { // Gets the results from the query $results = mysql_query($query, $this->connection); // Loops through the queried results as an multi-dimensional array while($rows = mysql_f...

Finding MySQL errors from LOAD DATA INFILE

I have a very large set of files and one of them is showing errors when I import it into mysql from the commandline mysql> prompt. I'm not sure how to check the data so the only thing I have to go by is the fact that the prompt reports 65,535 warnings on import. mysql> use dbname; Database changed mysql> LOAD DATA LOCAL INFILE '/dump.tx...

MySql Audio Library

I'm coding in ASP.NET and want to store audio files (.mp3, or smaller formats) in a MySQL database; which, I can then retrieve based on certain conditions. Is this possible? Are there any preferred methods to having Audio files on your web pages (besides embedding them in the HTML). ...

PHP session save_handler user (mysql) won't save

Hey guys, here's what I'm attempting: PHP sessions work by default with my configuration, if I just go session_start() and try the standard session increment test it works. if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } else { $_SESSION['count']++; } However I want to use a MySQL table for session storage. I've ...

Ruby (not Rails) giving a NoMethodError when using find()

I have a couple of scripts that interact with a MySQL database using ActiveRecord without the rest of the Rails package (although I have the complete Rails gem installed). However, trying to use these classes lately has been giving me the NoMethodError when I try to call find() on my ActiveRecord-descended class. The class code is amazi...

.XDR to MySQL data migration

I have .xdr file and I need to store it's data into mysql database. How should I do this? Thank you! ...

PHP - Compare exploded word with mysql varchar in PHP

How can I compare exploded word with mysql varchar in PHP? This code produce what i want but it also give this error veranderenwachtwoordjij Fatal error: Call to a member function fetch_assoc() on a non-object...... $word = "Also, to be safe, change your password regularly... you don't have to be obsessive about it: every three hours o...

Simple SQL problem (mysql)

SELECT username, (SELECT follow FROM follow WHERE follow_user_id = user_id) AS following FROM user WHERE user_id = 1 I want to know how I can check if follow (sub-query (select follow ...)) returns a value. If it did, then replace it with 'yes'. If it didn't, then replace it with 'no'. ...

MySQL: Update all Columns With Values From A Separate Table

Sometimes if I want to quickly copy records from one table to another (that has the same structure) I use a query like this: INSERT INTO table2 SELECT * FROM table1 WHERE id = SOME_VALUE How can I add a ON DUPLICATE KEY UPDATE to this statement? I tried this: INSERT INTO SELECT * FROM table1 WHERE id = 1 ON DUPLICATE KEY UP...

What is the best method for sorting columns with PhP and MySQL?

Hello, I would like to know which is the best way to sort table columns with PHP and MySQL. Is there a way to do this without having to set a variables like the following? $strASC = $_GET["order"]; if ($strASC == "ASC") { $strASC = "DESC"; } or does exist an SQL query that reverses the ASC or DESC depending on current status? ...

How to keep two development databases in sync with Doctrine?

(Make this CW if needed) We are two developers working on a web application based (PHP5, ZF, Doctrine, MySQL5). We are working each with a local webserver and a local database. The database schema is defined in a YAML file. What's the best way to keep our database schemas in sync? Here's how we do it: Whenever developer "A" makes a ch...

How to update DB structure when updating production system without doing a teardown / rebuild

If I'm working on a development server and have updates to the database structure for some of our releases, what is the best way to update the structure on the production server? Currently we create a new production database containing the structure only, do a SQL dump of the data on the 'old' production database, then run a SQL query t...

How to import DB tables from mysqlhotcopy?

I used mysqlhotcopy to dump a database full of tables. I know have various .frm, .MYD, and .MYI files that I need to import into a different instance of MySQL. Do I just copy these files into a specific folder on the 2nd system, or do I have to run mysqlhotcopy with another command line option to perform the import? ...

Can wildcards be used on tablenames for a GRANT in MySQL

Is it possible in MySQL to do a GRANT to a user on a set of tables within a database, e.g. to allow CREATE AND DROP ing of some table names but not others? Neither of these seem to work: GRANT SELECT ON `testdb`.`%_testing` TO 'wildcardtest'@'localhost'; GRANT SELECT ON `testdb`.`testing%` TO 'wildcardtest'@'localhost'; and the M...

Extended updates, is there such a thing?

Quite simple really, in a php/mysql set up, I have to run around 2M point updates on 25M items (where one update covers multiple primary keys), is there a way to pull this off with the same sort of gains as extended inserts? I'm using unbuffered queries already. Its slow. NB: Searching came up with nothing, this is on a dev environment...