mysql

MySQL syntax:You have an error in your SQL syntax....

I have written a very simple function: function editCategory() { $ID = urlencode($_GET['id']); $cname = mysql_fix_string($_POST['cname']); $kabst = mysql_fix_string($_POST['kabst']); $kselect = $_POST['kselect']; $subsl = $_POST['subsl']; $kradio = $_POST['kradio']; $ksubmit = $_POS...

problem in counting children category

I have this table: fourn_category (id , sub) I am using this code to count: function CountSub($id){ $root = array($id); $query = mysql_query("SELECT id FROM fourn_category WHERE sub = '$id'"); while( $row = mysql_fetch_array( $query, MYSQL_ASSOC ) ){ array_push($root,$row['id...

Php/Mysql - need help to insert and update multiple rows with a single query

Hello, is there any way how in this situation insert and update DB with single queries? $message = 'Hello to all group members'; $userdata = mysql_query("SELECT memberid, membernick FROM members WHERE groupid='$cid'") or die('Error'); while(list($memberid, $membernick) = mysql_fetch_row($userdata)) { $result1 = mysql_query("I...

NHibernate and mysql timestamp

I am trying to do versioning with NHibernate and everything works fine, however right after the insert NHibernate tries to pull the generated timestamp by executing the following query: SELECT profileloc_.Updated as Updated14_ FROM profile_locale profileloc_ WHERE profileloc_.id=?p0 and profileloc_.culture=?p1;?p0 = 16, ?p1 = 1033 Wh...

Are default mysql parameters in RDS sane?

RDS uses the same set of parameters for all instance sizes and they don't seem to be that far from defaults (max_packet_size being too small etc.) Has anyone looked at them and reviewed them for how sensible they are, especially on relatively bigger instances? ...

Rails more statements with ; doesnt work... :s

I have this code, but i cant make it work: images = Image.find_by_sql('PREPARE stmt FROM \' SELECT * FROM images AS i WHERE i.on_id = 1 AND i.on_type = "profile" ORDER BY i.updated_at LIMIT ?, 6\'; SET @lower_limit := ((5 DIV 6) * 6); EXECUTE stmt USING @lower_limit;') I got this error: Mysql::Error: You have an error in your SQL sy...

MySQL won't use index for query?

I have this table: CREATE TABLE `point` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `siteid` INT(11) NOT NULL, ...

Can there be TEXT/BLOB columns in a table without filesort in MySQL?

Hi, I'm working on a database program and I noticed that when I'm doing queries with tables that have TEXT/BLOB columns, MySQL will use temp tables and use filesort. I'm not entirely sure when and how this happens, but are there cases where MySQL does not use filesort when there are BLOB/TEXT columns? Like if the sort column is type of ...

Are there drawbacks to altering MySQL table data types?

Hi, I'm wondering that how much worried I should be about data types. I can easily jump from TINYINT to SMALLINT and from SMALLINT to INT, but are there any drawbacks to this? Obviously situations like from text to int will have consequences, but I'm talking about situations like INT->BIGINT, TINYTEXT->TEXT, etc. ...

How to select parent row only if has at least one child?

I have a simple one-to-many relationship. I would like to select rows from the parent only when they have at least one child. So, if there are no children, then the parent row is not returned in the result set. Eg. Parent: +--+---------+ |id| text | +--+---------+ | 1| Blah | | 2| Blah2 | | 3| Blah3 | +--+---------+ Childre...

Counting the most tagged tag with MySQL

Hi folks My problem is that I'm trying to count which tag has been used most in a table of user-submitted code. But the problem is with the database structure. The current query I'm using is this: SELECT tag1, COUNT(tag1) AS counttag FROM code GROUP BY tag1 ORDER BY counttag DESC LIMIT 1 This is fine, except, it only counts the ...

How can I split mySQL query logs by database?

I've been trying to implement a mySQL Proxy solution that can separate out the queries into per-database logs. Everything I've Googled has pointed to mySQL Proxy but I can only seem to capture the database a connection was opened to, not which the current query is being issued against. Is it even possible? Is there a different tool to u...

MySQL: Order by field size/length

Here is a table structure (e.g. test): __________________________________________ | Field Name | Data Type | |________________|_________________________| | id | BIGINT (20) | |________________|_________________________| | ti...

PHP/MySQL - Special characters in URLs. How to avoid?

Hey everyone, My database contains information extracted from an external feed. In this raw text feed, the following text is used in place of special characters: & - & ' - &39; é - é I extract some of this text to form URLs. For example, a URL that I construct from data containing these characters might look like this: ht...

Optimising (My)SQL Query

I usually use ORM instead of SQL and I am slightly out of touch on the different JOINs... SELECT `order_invoice`.* , `client`.* , `order_product`.* , SUM(product.cost) as net FROM `order_invoice` LEFT JOIN `client` ON order_invoice.client_id = client.client_id LEFT JOIN `order_product` ON order_invoice....

Why doesn't MySQL support millisecond / microsecond precision?

So I just found the most frustrating bug ever in MySQL. Apparently the TIMESTAMP field, and supporting functions do not support any greater precision than seconds!? So I am using PHP and Doctrine, and I really need those microseconds (I am using the actAs: [Timestampable] property). I found a that I can use a BIGINT field to store t...

Socket operation on non-socket

I'm running mysql5 on Mac os x 10.5.8 and got this error. How do I solve this? The DB worked fine but stopped working after system update. I think its something related to the socket file which is /tmp/mysql.sock do I need to give it special permissions and owner? Thanks ...

XML flat file vs. relational database backend

Most projects now need some form of a database. When someone says database, I usually think relational databases, but I still hear about flat file XML databases. What parameters do you take into consideration when deciding between a "real" database and a flat-file XML database. When should one be used over the other, and under what cir...

Resetting Objects vs. Constructing New Objects

Is it considered better practice and/or more efficient to create a 'reset' function for a particular object that clears/defaults all the necessary member variables to allow for further operations, or to simply construct a new object from outside? I've seen both methods employed a lot, but I can't decide which one is better. Of course, f...

Usage of Memcache to improve performance of MySQL Query

Is is always advantages to use memcache to improve performance of MySQL query ? Are there any downsides of extensive use of Memcache ? ...