mysql

MySQL structure for following multiple content types

I'm building a web app that will (ideally) allow users to follow discussion threads (which are in Q&A format like this site), but also follow other content types, such as firms and schools that have profile pages. (The site is intended to help with professional job-seeking, so the back-end provides a bare-bones profile page for firms, s...

In MySQL, how do I write a query to skip a duplicate row while inserting, when there's no unique field (primary key)?

I am trying to insert rows into a table that has no unique field or primary key. How can I write a query that will simply ignore the insert if there already exists a row with the exact same values on all fields -- a duplicate row? Thanks. ...

Retrieving alternate attribute values in GROUP BY query?

Let me explain what I mean with that question: Lets say I have to tables like these: customers id customer location 1 Adam UK 2 Pete US values id value 1 10 1 7 2 3 2 41 Let's ignore here for a moment that that (and the following query) wouldn't make a lot of sense. It's meant as a simplified example. Now, if ...

How do I create same username and password at phpBB forum as the username and password already saved

Hi. I have a site where all users need to sign up with username and password. Today I added the phpBB forum to my site. The problem is that users need to sign up for my site and the phpBB form separately. Can I just add to the phpbb_users db with php at the same time as they register for my site? In that case I need to know what kind o...

How expensive is find('count') in CakePHP?

I have a CakePHP application where I am trying to get a count of how many of each type of post a user has. I am also using the paginate helper to display all the user's posts on their profile. I could: 1) Make a find('all', $conditions) request for all the user's posts then parse that for the counts I need (by going post by post and chec...

Uploading images to Remote Server, iPhone

Hello, I would like to take images from library, or camera and upload them to a remote server, where I could then retreieve a URL for each image uploaded. Im looking to get started from scratch. And am looking for some help on where to start. Im need to do this the simplest way, php and mysql. Where should I start?! Also, I rather no...

SQL query: Get average, and average of everything higher than some value, in same query

I have a column of numbers in a MySQL database, along with a timestamp column and other stuff. I want to know the average of all of the values within a set parameter (say, within the last week), and I also want the average of all of the values that are >= X during that same timeframe. So, if my X is 10, and my values are: 0 0 10 15 20, t...

Creating a different user for each concern of my application!

I want to create my site and in the page have it so that the forum pages will use the forum mysql user having privileges on mydb.forum_table, mydb_forum_table2. and the profile page to use the profile user having access to mydb.users and mydb.profiefields and so on with the photogallery, blog, chat and... is this the right way to do it!...

NHibernate CreateSqlQuery and addEntity

The hibernate manual says this: String sql = "SELECT ID as {c.id}, NAME as {c.name}, " + "BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} " + "FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID"; List loggedCats = sess.createSQLQuery(sql) .addEntity("cat", Cat.class) .addEntity("mother", Cat.class).l...

How to create a new Server Instance on MySQL Workbench 5.2.25 CE

Hi, I've just setup MySQL Workbench 5.2.25 CE on a PC with windows XP service pack 3 When trying to create a new server instance on the localhost, Workbench ask me for a root password regarding the service. I've have not been asked during the setup process to enter a password for root... leaving the password blank (or even inputting a ...

Suggest me optimized query using 4 tables ( RIGHT JOIN v/s INNER JOIN & HAVING )

Hello ALL, I have following table structure table_country ==> country_id (PK) | country | status table_department ==> department_id (PK) | department | country_id (FK) table_province ==> province_id (PK) | province | department_id (FK) table_district ==> district_id (PK) | district | province_id (FK) NOTE: all tables engine are inn...

How do you properly set a blank variable as NULL

I am parsing an XML feed into a MYSQL table using simplexml_load_file(). Some of the variables are blank, I would like them to be actual NULL instead of NULL, or is there even a difference? $xml = simplexml_load_file('cb.xml') or die ('Bad XML File'); foreach($xml->item as $item) { $name = $item->name; //Tried if ($name == '') { ...

Query to find topics depending on the tag

Hi All, I want a search functionality in my application for the data like following topic_id tag 1 cricket 1 football 2 football 2 basketball 3 cricket 3 basketball 4 chess 4 basketball Now when i search for term cricket AND football o/p should be topic_id ...

Database design for affiliate system

i am building an affiliate system and i have stacked with the design of the database in one part. I dont know how to keep track on that who recruited whom. Lets say we have something like this: Jon smith Alex Del Jim West Marko Polo Johny Bravo Pit Sampras Sara Mat Gabriella white Antonio Santo Maja Grozdanova Agon Xhela...

chat rooms implementaion

hi everyone can you give me an idea about how to implement chat room using PHP and MySQL Thanks ...

PHP: What do you use to write it?

Possible Duplicate: What is the best IDE for PHP ? Hello again everybody, I finish my work placement next week and have over a month off before I start my studies again. Being the super cool party animal that I am I have decided to use the time getting a firmer grip on PHP. I recently bought the highly recommended book 'PHP ...

How do I get this 2 SQL querys to be 1

Tables are: user_table(user_id, user_name) , votes_table(id,user_id, vote_date, votes) $sql = SELECT user_id, sum(votes) AS sumvotes, vote_date FROM votes_table WHERE vote_date > 1279749600 ORDER BY sumvotes DESC LIMIT 10 $result = query($sql) foreach user_id in $result $sql = SELECT user_id, username FROM ...

How do I store a zip file in MySQL?

I want to write a program which will backup an entire drive in a MySQL server using java, but I am confused. How do I create the table (what data types?), how do i insert the row like what should be the primary key, and what should be the max size of each file be? If you have any suggestion please help me out. Thank you for sparing yo...

Codeigniter - Blank screen when trying to retrieve 8500 records

Hi, I am trying to display a table which contains 8500 records, I am using the same controller/model functions as I have used throughout the site which all work fine. On this page however, I just see a blank screen. Is this a known Issue with codeigniter? Is there a work around? I am totally stumped, my only option I guess is to split ...

ibatis + glassfish: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

I keep getting the error randomly: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Anyone got ideas? ERROR: java.sql.Connection - Error calling Connection.setAutoCommit: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from ...