mysql

symfony doctrine data-dump and reload wont't work

Hi, I have a database built by Doctrine from schema.yml which I want to modify. Thus, first I saved the data using doctrine:data-dump command. Afterwards I wanted to check if it really can reload data, so I called the doctrine:build --all --and-load command. It successfully rebuilt the database, however when loading data from data1.yml...

DB table getting too much data - need another solution

I have a site where people can add their favorite TV series. There is one feature that makes it possible to check off episodes that you have seen. Each episodes that is checked off, creates one record in a DB table (with user_id, show_id and episode_id). This table is now over 600.000 rows and is growing very fast! I have indexes set u...

SQL: is it possible to combine an INSERT and SELECT statement into one

I want to add a row using SQLs INSERT statement. Is it possible that as part of this statement I can somehow get the value of the column userId which I don't update but is the AUTO_INCREMENT primary key. I need this value to update another table, however I can't follow the Insert statement immediately with a SELECT statement as there is ...

Handling Internet Connection Hiccups and Database Connections

I realize that there is no way to atomically guarantee: if(hasInternet) doDatabaseCall(); However, what is the correct way of handling connection problems when dealing with DbConnection and DbCommand objects in the .NET world? I'm specifically interested in the MySqlConnection and MySqlCommand objects but assume (hope) its patter...

Mysql subquery problem

Hi, I have 2 tables: loans (columns: id, user) payback (columns: id, installment, scheduleDate) If a loan is to be paid in 12 installments, then there are 12 payback records with loan id. I would like to find out what users have a scheduleDate on which the sum of all their paybacks is greater than 2000. SELECT user FROM {loans} ka...

Storing a User's Signature in MySQL

I need to store user's signature (ie the thing at the bottom of a forum post) and am not sure how to, I could use text to store the html, but I think there are probably better solutions. ...

MySQL Connector/NET - support for transactions under Mono

Does anyone know how to get MySQL transactions working under Mono? I'm using MySQL Connector/NET (via Subsonic 3) and it works perfectly under Microsoft .NET. Recently however I tried running the same site under Mono on Ubuntu and it almost works - except I can't seem to get transactions working. Reading around the Mono/MySQL sites ...

Rails, MySQL, Unicode data and latin1 tables - Where to go from here?

I'm not 100% sure on the particulars, so I'd love someone straightening me out, but I'll forge ahead with what I think is going on... When I first setup my database, I used the default character encoding of the system without even thinking, and it was latin1. I never even thought about i18n/l10n. It just didn't occur to me. I just accep...

MYSQL DB- How to transform NESTED SETS to XML?

Hi, I'd need a MySQL query to transform my nested sets structure into XML. (no PHP) The Problem is how to close all tags correct. My method of resolution: 1) Find leaves 2) Make a "TAG"-string (group_concat) and make it shorter with level This is running: A[01,16] B[02,03] C[...

PHP File existence check vs MySQL SELECT server load.

Hi guys, i'm implementing in a project of mine an ip banning functionality. First of all, i'd like to avoid .htaccess for this purpose 'cause the CMS probably would reset it upon modifications, so i have to use a PHP-send-header-and-die solution. Obviously every HTTP request will be checked. Considering an highly trafficated site, i hav...

Nested SQL Query

I have the following tables: Club: Club_ID | Title | Created_Date | ... Club_Intesect: User_ID | Club_ID | Access I'm trying to select a variable number of clubs, and join the ID of the user with the highest access in that club. This person is considered the owner. So if Club 100 has Members A, B, C with access 3,4, and 5 ...

mysql: using one field to contain many "fields" to save on fields

Hi I have a project which needs an Excel GUI (client's request) with a backend mysql db/table requiring almost 90 fields. (almost 60 fields are duplications of 6 fields.) After giving it some thought, I ended up creating a table with 11 fields: 10 searcheable fields, and one big field which can contain up to 60 fields "together", separ...

Don't understand the date format in mysql like 1286066935 - UserCake

Hello People, I'am using UserCake for UserManagement - in the table userCake_Users there is a column "LastSignIn" but the value is in this format: 1286066935 with this function I get the right Date public function updateLastSignIn() { global $db,$db_table_prefix; $sql = "UPDATE ".$db_table_prefix."Users SET ...

Determine status of an index

Hi I created a new index on a table with 35million records and its been running for nearly 1 day now. Previously when I created indexes it took 20 minutes, there columns were however floats. The new idnex is on a varchar(45) I used the processlist command which shows the index creation is still in progress with the following output 6...

Listing tables in mysql database

Hello How do you list the names / fields of all the tables in a mysql database ? Any code examples would be helpful, Thanks! ...

Wordpress Post Loop Based On Selecting 10 Post Id's from DB?

I've spent most of today looking for info on how I can get 10 post ID's (which dynamically change every day) from table name wp_recently_popular row post_id and create a loop that uses those id's to call the post info so I can have those 10 posts on my homepage. All day long and everyone is showing the same tutorial over and over again....

Newsletter Categories in one row like 1,2 - Mysql Simple Database Design

Hi, I'am using a simple newsletter-script where different categories for one user are possible. But I want to get the different categories in one row like 1,2,3 The tables: newsletter_emails id email category 1 [email protected] 1 2 [email protected] 2 newsletter_categories id name 1 firstcategory 2 secondcategory ...

Mysql transaction question

My code: mysql_query("SET AUTOCOMMIT=0"); mysql_query("START TRANSACTION"); insert_query, update_query1, update_query2 mysql_query("COMMIT"); update_query3 Why does update_query3 query doesn't work if I put it after COMMIT? It works if I put it before the COMMIT. Why is that? It's really strange. Thank you ...

How can I sort by the average of a polymorphic child's attribute with ActiveRecord 2.3?

I have this schema: class Comment has_many :ratings, :as => :target end class Rating belongs_to :target, :polymorphic => true end I want to write a named scope that will sort comments by their average rating, without fetching the whole list of comments and then fetching all their ratings. I think I need to use :include and :grou...

mysql comparing force BINARY

I have two tables. In one I have column like INT and in other I have row like VARCHAR where I wait user id or unique id for quest with letters...I want compare if INT = VARCHAR in mysql query. I am using: BINARY int_row = BINARY varchar_row is this ok ? ...