mysql

Trouble using MySQL transactions with loops in PHP

Hello all, I am trying to set up a MySQL transaction such that I can loop through a bunch of queries (see below) and if any of them fail, rollback all of the changes. I am finding however that if one fails, not all of the queries are rolled back. Am I doing anything wrong here? mysql_query("START TRANSACTION"); foreach($array1 as...

What's the meaning of "derived" in "GPL require derived works to be released under the same terms"

The GPL and AGPL require derived works to be released under the same terms,I don't understand the terms of "derived",what is the meaning of the "derived".If I develop a client software of mysql(mysql is license under GPL),I use some mysql lib,when I distribute it,may I have to make my software a GPL license?Navicat(a client software of m...

Implementing Gravatar into custom Commenting System.

Hi guys! I'm in the process of coding my very first blog. With the help of various tutorials, and other forums I have managed to gather a semi-working code. Right now I have a code that takes and displays the comment, but the problem is I wish to display Gravatars beside each comment. I was just wondering how exactly I would go about im...

How to extract a UTF-8 string (In Arabic) from a MySQL DB and echo to screen using PHP

Hi, I have a MySQL db, i've set collation = utf8_unicode_ci. I'm trying to fetch the value through PHP but i'm getting "???" instead of the actual string. I have read about this subject and tried using mb_convert_encoding but it didn't work, what am I missing? Can someone please post a code snippet that actually pulls a value from a ...

Joining multiple columns from table a to one on table b

I've spent a bit of time researching this on here and the mysql site but I'm a bit confused on two things: which sort of join to use and how (or if) to use an alias. The query: SELECT forum_threads.id, forum_threads.forum_id, forum_threads.sticky, forum_threads.vis_rank, forum_threads.locked, forum_threads.lock_rank, forum_threads.aut...

Hibernate getHibernateTemplate issue when saving object inside another object

I recently changed my code to make reference to the getHibernateTemplate(), and now my forms don't seem to save correctly, here's the code: public void saveForm(EcoFormFill form, int userId) throws RemoteException { User tmpUser = (User)getHibernateTemplate().load(User.class, new Integer(userId)); form.setUser(tmpUser); ...

How do I increment value with mysql update query (php)

Hi. I have a query that look like this: $sql = "UPDATE tbl SET amt_field='amt_field+1' WHERE username='" .mysql_real_escape_string($_SESSION['username']). "'"; mysql_select_db('db',$con); mysql_query($sql,$con); I want to increment the value as easily as possible I have tried : "UPDATE tbl SET amt_field='amt_field+1'...

PHP MySQL Query Question / Help - Joining tables

Hi, I need to help to show wall posts from the friends of the logged in user, and the user himself ofc.. :P I've searched on every coding forums, and google, did not find the answer I was looking for :/ The Session for the logged in user are: $_SESSION['userid'] This is the MySQL Query I have so far: SELECT DISTINCT * FROM status_up...

Various ways to query strings?

I'm working on an app that involves a lot of carefully designed strings. I'm in the process of designing the string format and for that I need to know what's possible and what's not when I'm querying the same data. Which ones of these are possible with MySQL? .. and how do I accomplish them? Results which contain this exact string -- ...

Change MySQL ending statement.

This question I am asking by proxy (it is for someone else). He is making a program and have the following problem: He need to input unescaped ";" into a query, he heard that he could ask MySQL to terminate with something else than ";" So, in pseudocode it would be: Change_Statement_Ending(;;); SELECT * FROM * WHERE;; //suppose that t...

a question about mysql select query!

I have a list of events for example I wanna show on a page with the users that have created them which is all in a table and the user who has created them's unique id, now if I wanna show their username and avatar I would have to run 100 queries inorder to show 100 events! but I'm sure their is a easier way I don;t know! i have a table ...

Grouping multiple MySql queries

Hello everyone, I have a simple query as listed below SELECT id, name, email FROM users WHERE group_id = 1 This works great until, I then start adding LIKE queries, chained with OR statements to the end. SELECT id, name, email FROM users WHERE group_id = 1 AND id LIKE $searchterm OR name LIKE $searchterm OR email LIK...

MySql - Order by date and then by time

Hi! I have a table with 2 'datetime' fields: 'eventDate' and 'eventHour'. I'm trying to order by 'eventDate' and then by 'eventHour'. For each date I will have a list os events, so that's why I will to order by date and then by time. thanks!! ...

How to delete from multiple tables in MySQL?

I am trying to delete from a few tables at once. I've done a bit of research, and came up with this DELETE FROM `pets` p, `pets_activities` pa WHERE p.`order` > :order AND p.`pet_id` = :pet_id AND pa.`id` = p.`pet_id` However, I am getting this error Uncaught Database_Exception [ 1064 ]: You have ...

mysql query to update field to max(field) + 1

What I want to do is: UPDATE table SET field = MAX(field) + 1 WHERE id IN (1, 3, 5, 6, 8); The semantics of this statement, in my mind, would be first the database would go off and determine for me what the largest value of field is in all of table. It would then add 1 to that value, and assign the resulting value to the field column ...

Tomcat Mysql connection hangs after about 30 minutes

Facts: 1 Tomcat installation , 1 MySql and 2 applications ( app1 and app2 ) Hosted on shared hosting, so most of admin stuff with mysql is not possible When tomcat is started the applications ( both app1 and app2 ) are working fine After about 30 minutes... I try to log in my app1 Sometimes it logs in and sometimes it just sits there a...

MySQL Limit, Group, and AVG Query

Here's a puzzler for you: I'm keeping stats of cluster computing stuff in a MySQL table named 'jobs'. Each job row has a host the job executed on (not unique), a job execution time in seconds, and a unique integer as the PK so I can order the completed jobs simply by ordering the PK. As of right now, using average and group by, I can ...

Can't create a Many-To-One relation with all-delete-orphan cascade. MySQL says a foreign key constraint fails when deleting the parent.

Hi, I started using Hibernate recently and I'm still a newbie, however, the error I'm facing doesn't seem to be simple. My current environment is: Windows 7 MySQL 5.1.49-community mysql-connector-java-5.1.13-bin.jar hibernate-distribution-3.6.0.Beta1 I'm following the "Hibernate in Action" book and did everything exactly the way...

I need to know how i can write IF statements and CASE break statements that use and execute queries, etc in MySQL ?

I need to execute a query that is highly dependent on several conditions what need to be checked by analyzing that data in other tables, the base goal is to return the rows from the tables if all of the conditions in the other tables are true, I am fed up with INNER joins LEFT joins and WHERE statement, i need to look up one table, if th...

Connecting to MySql on Mac: No suitable driver error

I am getting the error: java.sql.SQLException: No suitable driver I have imported the .jar file that is available here http://dev.mysql.com/downloads/mirror.php?id=13598 I am using Eclipse. I am connecting to the DB with this code: package dao; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; ...