mysql

MySQL: How to study/analysis a MySQL DB tables relationships?

I'm given a MySQL DB that contain 108 tables. Is there a way or tool (software) to be able to see how these tables are connected (hopefully in a visual way) so I would be able to understand the usage of each table and how everything is working together. I'm accessing them through something called "MySQL Tools" -> "MySQL Administrator" w...

Is there a way to get rows_examined in MySQL without the slow log?

I'm building some profile information for a home grown app. I'd like the debug page to show the query sent along with how many rows were examined without assuming that slow_log is turned on, let alone parsing it. Back in 2006, what I wanted was not possible. Is that still true today? I see Peter Zaitsev has a technique where you start ...

Fetch location of MySQL slow query log via PHP

How can I discover the filesystem location of the slow query log from php? I'd like to do this dynamically through a query (if possible, or some other runtime method) as opposed to parsing any my.ini files. ...

How can I determine type of mysql database : whether it is InnoDB or MyISAM ?

How can I determine type of mysql database : whether it is InnoDB or MyISAM ? How can I convert MyISAM to InnoDB or vice-versa ? ...

Storing Sessions in DB Table Not Working (using Zend_Session_SaveHandler_DbTable)

This is my table: CREATE TABLE `Sessions` ( `id` varchar(32) NOT NULL, `modified` int(11) default NULL, `lifetime` int(11) default NULL, `data` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB This is in my bootstrap: $sessionConfig = array( 'name' => 'Sessions', //table name as per Zend_Db_Table 'primary' => 'id', ...

Cannot load SQL driver in Visual C++ (but loads in QtCreator)

I have a QT application that requires the MySql driver. I have both a .pro file to compile the app with QtCreator and a .vcproj for Visual C++ 2008 Express. The code is identical and it compiles without a hitch, but the executable created by Visual C++ Express gives me the following output and refuses to load any driver/plugin: QSqlData...

Optimizing Mysql Query

What is the general "best practice" for this type of functionality. I have a table of users a table of polls and a table of poll responses on a website. I want to load a page that loads a poll that a user hasn't yet answer. What is the most efficient and "best" way of going about this. Things I've tried that seems slow/not optimal: ...

How do I use "mysql source" command with a mysql variable?

I need to execute from mysql shell an SQL file based on a condition like mysql> source @var where @var contains the filename ...

how can you read from database and write to the http stream. php & mysql

Hi, It is like continue getting data from mysql using PHP and simultaneously stream out to the http. Like in java we can write into ServletOutput stream? The size of the data can be like 200 MB. Thanks ...

Get current auto_increment value

I am doing mysql insert for my table using php. Autoincrement column name is "link_id" and "alias" colum is used to make SEO friendly url. During my insert, I would like to attach link_id value at the end of my alias column. So I need to know what is the being inserted link_id value. I do not want to do another query. mysql_insert_id...

MySQL Stored Procedures

Hi, I'm coming from a MS SQL Server background. Working on a new project using MySQL with NaviCat 8 Admin tools. Ok, here's the question. Normally when working in MS land if I want to update some data I use a stored procedure to do this: Drop Procedure spNew Create Procedure spNew (@P_Param) UPDATE Table SET Field = 'some value' WHERE ...

What are best practices for determining if I should create a new Drupal module?

I'm using Drupal for the first time for a project at work. I'm finally getting my head wrapped around some of the core concepts, but when it comes to customizing output I'm unsure of how to proceed. I have to build a fairly specialized image gallery. I've managed to cobble something workable together using Views2, but it's not quite whe...

json_decode on retrieved json string from mysql does not work

I have a string json that gives the following var dump: "[[{"TransactionID":"00416","OrderID":"000926","TransactionOrderItemID":"001123","LastUpdate":"2009-10-28 13:03:31","CustomerID":"184","Company_name":"Test123","Invoiced":"0","SubItemsCount":"2","ProductID":"1","ProductTypesID":"1","ProductTypeName":"Phone","ProductName":"Phone Lin...

PHP Array Duplicates

Hi there, my first post here and hoping someone can help. I am querying a table in a mySQL DB, and obviously getting the results. However, the table is used to store multiple entry by one user for the purpose of user contacts. What I would like to do is display each user individually, and count the number of contacts each user has. I ha...

Java enum to mysql enum in prepared statement.

Hi. With the regular statement (just statement) I can put java enums into the queries and it works just fine. With prepared statement I can't do this ? ...

ERROR IN MYSQL QUERY DATEDIFF() FUNCTION

Hi I am trying to calculate duration, I am using MySQL 5.0 but i am getting this error 1305 - FUNCTION smgm.DATEDIFF dose not exist MY QUERY IS SELECT DATEDIFF (MI,timein,timeout)/60 as duration FROM User_smgm where ID=2; my database name is SMGM Any Idea why is this so? Where as when i try simple DATEDIFF its working fine. such...

mysql command line. Empty set, 1 warning (0.01 sec)

How do i view the warning(s) after a SELECT query? The results of one query is Empty set, 1 warning (0.01 sec) I am using mysql via command line on linux. ...

Get the next xx:30 time (the next half-past hour) after a specified time

I'm trying to find a MySQL query which will obtain the time that is the next half-past-the-hour from a specified datetime. I explicitly mean the next half-past-the-hour, not the next half-hourly point. So for instance: If the datetime was "2009-10-27 08:15:24", the answer would be "2009-10-27 08:30:00" If the datetime was "2009-10-27 ...

mysql hanging while importing database dump

We have a db dump import script from our production db that we use to rebuild our sandbox dbs. The syntax we use for this is mysql -u uname -ppass dbname < prod_db_export.sql. The script proceeds to create the first table and then do this: LOCK TABLES `ad` WRITE; /*!40000 ALTER TABLE `ad` DISABLE KEYS */; /*!40000 ALTER TABLE `ad` ENABL...

Combine sql rows with same id, sum and update the total

Hello, I am attempting to write a php script to compare rows from the database and then adds the quantities it the product id matches. Based on cusotmer_id Example: mydb.cart id, customer_id, cart_id, product_id, qty, price 1, 0001000, 4545453, 20, 10, 12.99 2, 0001000, 7473432, 20, 2, 12.99 Result 3, 0001000, 7473432, 20, 12, 25.9...