mysql

Is there a programmatic way to check the syntax in a .sql file?

Hi, Is there an opensource library that checks/validates the syntax of an .sql file at runtime? Thanks in advance! Connie ...

Symfony Update a Model Schema

So heres the scenario: Currently we have a development site with 3 models. We found we didn't like our initial schema and added a few rows. We re-generated the schema (doctrine:build-sql). Now it forced us to drop and re-create all the tables and dump back in all the information as no ALTERS were created but rather CREATE statements o...

Does PHPMyAdmin pose security Risk on production

The VPS I was using used to have PHPMyAdmin pre-installation option but removed it stating it poses security risk. Does it? If so do you recommend an alternative for browsing DB on production (other than running SQL commands in console) ...

How to model a database where one page can have different content types?

I have the database table page with the fields contenttype_id and content_id. I want to link a page to a contenttype via contenttype_id and refer to an actual content via content_id. The problem is contents depend on the contenttype_id and are modelled differently, therefore the content_id refers to different tables depending on the cont...

In MySQL, ' results in error, ` works fine. why?

$query = "SELECT * FROM `users` WHERE `username` = 'admin'";#works $query = "SELECT * FROM 'users' WHERE 'username' = 'admin'";#does not work Is this yet another quirk Im going to have to get used to, or is something funny going on? ...

MySQL Self-Join

Hi All, I have a table (this cannot be changed) like the following: POST_ID | PARENT_ID | POST_NAME 1 | 0 | Services 4 | 1 | Development 5 | 4 | Magento 2 | 0 | Contact The field, 'parent_id' references post_id to form a self-referential foreign key. Is it possible to write a s...

How to filter mysql duplicated id rows and retrieve the one with latest timestamp?

I have a mysql table with entries like this: id name value date 1 results1 1000000 2010-06-02 01:31:12 2 results2 600000 2010-09-03 05:42:54 1 results1 1200000 2010-09-06 02:14:36 How can I SELECT all and filter multiple rows that have the same id, selecting only the one with latest date? The "date" column d...

mysql select minimum that is not a duplicate

I'm trying to write a query that will display the minimum value (lowest score) for each hole eliminating any duplicates. In other words, if the minimum score is 3 on hole_num 1 and there are two or more scores with 3, none of the rows corresponding to hole_num 1 should be returned. However, if there is only one value of 3 on hole_num 1 ...

Having trouble with MySQL division query (probably simple fix)

I'm trying to figure out the overall ratio for users. There is basically two columns I need to look at to figure out the ratio, total_emails and total_hours. SELECT sum(total_emails/total_hours) as ratio FROM table WHERE id= 1 LIMIT 0, 1; This appears to adding the ratio up multiple times and I get a number like 8.45 when I should be...

MySQL Stored Procedure dynamic change name of table.

Hello, I wanna change dynamicaly name of table in sql query. For example I have next stored procedure: CREATE PROCEDURE NewProc(IN tableName varchar(64),IN message text) BEGIN INSERT INTO tableName VALUES (message); END; I need to change tableName in runtime, Can I to do it or not? Thanks. ...

Wordpress: Error establishing a database connection. Yeah, I've tried that. And that...

This is driving me nuts! I have a test instance of Wordpress installed on my MacBook Pro, which has suddenly stopped working. If I head for http://localhost:9003/wp-admin/ I get: Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or ...

In MySQL, how to JOIN two very large tables which both have columns in the WHERE condition?

I'm trying to determine the best general approach for querying against joined two tables that have a lot of data, where each table has a column in the where clause. Imagine a simple schema w/ two tables: posts id (int) blog_id (int) published_date (datetime) title (varchar) body (text) posts_tags post_id (int) tag_id (int) Wi...

multiple ->select() in doctrine query

Hi, for a doctrine model I'm making I don't always need to fetch all the columns I was hoping that I could solve this using $query = Doctrine_Query::create() ->select('a'); if(!empty($value)){ $query->select('b'); } $query->execute(); but this does not work... Does anyone have a clue how this could be done? ...

getting previous and next record in MySQL when ordering by date and allowing duplicate dates

I've tried looking up other help for this problem but I'm just not getting it. Suppose I have a table that looks like the one below. +----+--------------+------------+ | id | date_col | label | +----+--------------+------------+ | 1 | 2010-09-07 | Record 1 | | 2 | 2010-09-03 | Record 2 | | 3 | 2010-08-23 | Record 3...

Save HTML code in MySQL

I am going to save a HTML code base page as my data in mysql.... can i do it or I have to save it as a html file and get it again? ...

MySQL -- Better way to do this query?

This query will be done in a cached autocomplete text box, possibly by thousands of users at the same time. What I have below works, bit I feel there may be a better way to do what I am doing. Any advice? UPDATED -- it can be 'something%': SELECT a.`object_id`, a.`type`, IF( b.`name` IS NOT NULL, b.`name`, IF( c.`name` IS...

The best database class or functions for PHP?

I going to start to write a new software with PHP, and I need to know the best way to use database. Should I choose a database class such as Adodb, ezSql etc. What do you think which class is the best one? ...

News feed help for activity stream

building a facebook-like newsfeed and need help. We would like to start off with just comments in the news feed. We would like to display all of the comments of everybody the current user is following on the site. There is a followers table with the follower id and the followee id. Here is a basic query of the followers table to select ...

Web-Based PhpMyAdmin Alternatives?

I'm looking for a web-based Mysql alternative to PhpMyadmin that could run of a windows box... not sure if there's anything out there... can run PHP, but would like something that would actually allow me to setup different DB connections on remote machines. Thanks! ...

MySQL: What is the key buffer

Hello... I'm trying to tweak my MySQL server to fit my needs... and I have a basic question: What is the key buffer? Through try and error I've found that a bigger key buffer makes my inserts faster... but I don't quite understand what it is. So... before I make something I might regret, I'd like to know what it is, and how it works. J...