mysql

Deleting huge chunks of data from mysql innodb

I need to delete a huge chunk of my data in my production database, which runs about 100GB in size. If possible, i would like to minimize my downtime. My selection criteria for deleting is likely to be DELETE * FROM POSTING WHERE USER.ID=5 AND UPDATED_AT<100 What is the best way to delete it? Build an index? Write a sequentia...

Why entered key word is not store in database?

Hey Guys, I had made on form, in which i had one text area. Now i am storing that data of text area to mysql database. Now if i had press enter key word then it not stores in the database. Because i don't get exacted output as what i entered. as example... If i had write like this..... GoodMorningHow are you? then i only get like th...

How is database performance impacted when the mysql innodb database is very large?

I am currently making a decision on how i can reduce the size of the database. Why is performance slowed down when a database is slow? ...

How to change this mysql select into sql server select statement?

I use this mysql statement for concating description which has a length greater than 30.. select if (CHAR_LENGTH(description)>30,CONCAT(SUBSTRING(description,1,30), '.....'),description) as description from table How to change this mysql select into sql server select statement? ...

data caching in mysql

can we cache queries in mysql with php. or please suggest me some ways to do so. ...

MySQL connection attempt works fine in 5.2.9 but not in 5.3.0 - Help?

Hi, I'm having trouble making a secondary MySQL connection (to a separate, external DB) in my code. It works fine in PHP 5.2.9 but fails to connect in PHP 5.3.0. I'm aware of (at least some) of the changes needed to make successful MySQL connections in the newer version of PHP, and have succeeded before, so I'm not sure why it isn't wor...

Getting the most recent post based on date

Hi guys, How do I go about displaying the most recent post when I have two tables, both containing a column called creation_date This would be simple if all I had to do was get the most recent post based on posts created_on value however if a post contains replies I need to factor this into the equation. If a post has a more recent repl...

Set data from one specific field into a variable with PHP

i have to get data from one specific field in my database and set it into a variable (most likely this has to go into the controller), so that i can echo this on multiple pages in my webapplication. don't know if it's necassery to say, but i make use of the cakePHP framework. thanks in advance! ...

Encoding problem (Hebrew UTF8) in WordPress

Hi all, I have a blog (of a friend) I am failing to fix: http://www.nivcalderon.com/ The language of the website is Hebrew, but the encoding scrambles the output, and I can't find how to fix it. I tried changing the DB colliation to be utf8_general_ci. I added this: define('DB_COLLATE', 'utf8_general_ci'); To the wp-config (and ...

dynamic searchable fields, best practice?

I have a Lexicon model, and I want user to be able to create dynamic feature to every lexicon. And I have a complicate search interface that let user search on every single feature (including the dynamic ones) belonged to Lexicon model. I could have used a serialized text field to save all the dynamic information if they are not for se...

How to update existing record if the one being saved has the same key?

MySQL has a very nice option for INSERT statement, which is particularly helpful for join tables without the id column. It inserts a record, but, instead of throwing an error if its key clashed with the existing one, that record is updated. Here's an example: INSERT INTO table (key1,key2,data) VALUES (1,2,3) ON DUPLICATE KEY UPDATE ...

MySQL: How can fetch SUM() of all fields in one Query?

Hi, I just want somthing like this: select SUM(*) from `mytable` group by `year` any suggestion? (I am using Zend Framework; if you have a suggestion using ZF rather than pure query would be great!) Update: I have a mass of columns in table and i do not want to write their name down one by one. No Idea?? ...

Beginner PHP: I can't insert data into MYSQL database

I'm learning PHP right now and I'm trying to insert data into a MySQL database called "pumpl2" The table is set up like this. create table product ( productid int unsigned not null auto_increment primary key, price int(9) not null, value int(9) not null, description text ); I have a form and want to insert the fields from t...

Is this a secure way to structure a mysql_query in PHP

I have tried and tried to achieve an SQL injection by making custom queries to the server outside of firefox. Inside the php, all variables are passed into the query in a string like this. Note, by this stage, $_POST has not been touched. mysql_query('INSERT INTO users (password, username) VALUES(' . sha1($_POST['password']) . ',' . $...

How to implement XXTEA in MySQL?

Anyone knows how to implement XXTEA in MySQL? For example - SELECT xxtea_encrypt('text here', 'key here'); possible implementation is by creating a FUNCTION in MySQL using CREATE FUNCTION statement, e.g. CREATE FUNCTION xxtea_encrypt XXTEA Procedures here... RETURN encrypted string Thanks & Best regards ...

Can you use a prepared statement in MySQL with "On Duplicate Key Update"?

I can't find any reference to using prepared statements with "ON DUPLICATE KEY UPDATE" with MySQL and PHP. Am I correct in thinking that this is not possible? -Jim ...

Error 1005 when adding a foreign key constraint on mysql table

Hello, I have a problem when upgrading a django and mysql app with south. I've tried to make a sql-based upgrade with the code generated by the django sqlall command and I have a similar problem. Here is the sql code: CREATE TABLE `programmations_basissupport` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `value` numer...

Data aggregation mongodb vs mysql

I am currently researching on a backend to use for a project with demanding data aggregation requirements. The main project requirements are the following. Store millions of records for each user. Users might have more than 1 million entries per year so even with 100 users we are talking about 100 million entries per year. Data aggreg...

MYSQL and the LIMIT clause

I was wondering if adding a LIMIT 1 to a query would speed up the processing? For example... I have a query that will most of the time return 1 result, but will occasionaly return 10's, 100's or even 1000's of records. But I will only ever want the first record. Would the limit 1 speed things up or make no difference? I know I could ...

How to handle dates that repeat indefinitely

I am implementing a fairly simple calendar on a website using PHP and MySQL. I want to be able to handle dates that repeat indefinitely and am not sure of the best way to do it. For a time limited repeating event it seems to make sense to just add each event within the timeframe into my db table and group them with some form of recursi...