mysql

Zend DB and Conditional Case Statements

Hey, I have a zend app that displays a league table of race results. The basic process is to determine the list of events to be included, and then dynamically add a set of columns to a SQL query. My initial implementation is rather rubbish and i want to refector it. I manually build up a string of SQL and at the very end call db->fetch(...

php problem,whatwrong?

the image above say what the problem i face to. if the password and confirm password is not the same, the box prompt up to choose my DB user.why??? here my code : else if($_POST['submit']=='Save') { // If the Save form has been submitted $err = array(); if($_POST['confirmset'] != $_POST['setpass']) { $err[]='please make sure...

mysql date query which selects multiple dates

I need a single query that is similar to SELECT datetime FROM blog WHERE UNIX_TIMESTAMP(datetime) < '".($date_string_in_seconds +1000)."' ORDER BY datetime DESC but instead of returning the latest date that is smaller than the one given in parameter, it has to return: -the record with the exact date that is given in the parameter -if ...

Multi database schema export

Hello, I'm writing a project that will make use of mySQL or Derby (it must work in both situations). To solve this I'm using Hibernate and it works nicely, but for a situation: I've a couple of tables that contain cities and towns, with data related so that if i know the town I can join and get the county, state and zip code. These table...

Slow migrations on MySQL and MacPorts on Snow Leopard?

I reinstalled mysql5-server through MacPorts and suddenly my migrations started running a lot slower. rake db:migrate:reset used to take less than a second before. It takes 33s now. When I run it on a Linux machine (or even another Mac), it takes less than a second again. I remember encountering this problem in the past, but I don't reca...

How can SELECT UTC_TIMESTAMP() return -10:00 UTC???

Either I'm being stupid or something's wrong here. I have two SQL Servers, the one is on my local machine (local time +2 GMT) and the other is somewhere else (NOW() seems to return +8 GMT)and I access it through phpMyAdmin. I have a table that has a DATETIME column. I'm -trying- to store the current GMT/UTC time and then display it agai...

Performance gain or less using an association table even when there is just a one-to-many relationship

I am going to build a PHP web application and have already decided to use Codeigniter + DataMapper (OverZealous edition). I have discovered that DataMapper (OverZealous edition) requires the use of an extra association table even when there is actually just a one-to-many relationship. For example, a country can have many players but a ...

MySQL: Difference between `... ADD INDEX(a); ... ADD INDEX(b);` and `... ADD INDEX(a,b);`?

Can someone tell me what is the difference between these two: ALTER TABLE x1 ADD INDEX(a); ALTER TABLE x1 ADD INDEX(b); AND ALTER TABLE x1 ADD INDEX(a,b); I know this goes down to the very basics but sometimes I find the former seems to be a little faster than the latter. Is it just my feeling or is there some actual reason for it?...

Convert .xls file to xml using php

Hello all! I need to implement a functionality where a user can upload an Excel file, that is, .xls file and i need to write a function that will read that file and then save the values in a table, compare them to values in another table and then print some kind of billing quotation. From what I have read, it seems that the best way to...

Formatting column results in Doctrine ORM?

I have a timestamp field (using the timestampable template) that I want formatted differently in the results for only one SELECT query. Is there a way to pass in a date/time format string in the Doctrine_Query::create() method? Or maybe there's a way with ->setParams() or ->setOptions? I could format the date in the View using Zend_Da...

How to selectively dump all innodb tables in a mysql database?

Hi, I have a database called av2web, which contains 130 MyISAM tables and 20 innodb tables. I wanna take mysqldump of these 20 innodb tables, and export it to another database as MyISAM tables. Can you tell me a quicker way to achieve this? Thanks Pedro Alvarez Espinoza. ...

Who is throwing (and catching) this MySQL Exception?

i'm using Python with MySQL and Django. I keep seeing this error and I can't figure out where the exception is being thrown: Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in > ignored I have many "try" and "exception" blocks in my code--if the exception occurred within...

MySQL linking two tables without third table holding the relationship

Hi guys, say you have two tables table_a f1 <- PKEY f2 f3... table_b b1 <- PKEY b2 b3... now say table_a had a MANY to MANY relationship with table_b normally you'd have a third table to hold that relationship table_c c1 <- PKEY b1 <- PKEY of table_b f1 <- PKEY of table_a also say b1 + f1 for whatever reason could not be the ...

How to enforce uniques across multiple tables

I have the following tables in MySQL server: Companies: - UID (unique) - NAME - other relevant data Offices: - UID (unique) - CompanyID - ExternalID - other data Employees: - UID (unique) - OfficeID - ExternalID - other data In each one of them the UID is unique identifier, created by the database. There are foreign keys to ensure ...

MySQL Workbench: Generate a bunch of rows?

I have a MySQL workbench model that I've used to generate a schema. To play around with it, I'd like a bunch of fake data. Is there an easy way to generate this, or must I do it by hand? ...

JQuery Alert Problem?

I'm trying to get the following code to display only on specific pages but when I click through certain pages like the home page or any other pages that does not use this code I get the following `alert("some error occured, please try again later");. How can I have the code not display the alert box on pages that do not use this JQuery ...

How to create databases on mySQL using script (PHP, etc)

Hi, I am thinking of running a hosted service using Amazon Services (PHP + mySQL). What I like to do is have a site where someone registers, pays PayPal and returns to site where they will get an automated information to their mySQL account. So this mySQL account would only be used by them. They can create tables, etc. Some questions ar...

SQL: Select everything in a table not in a sub-query?

This query appears to work well: -- Every supplier that produces some red or green part SELECT Suppliers.sid FROM Suppliers, Catalog, Parts WHERE Suppliers.sid = Catalog.sid AND Catalog.pid = Parts.pid AND (Parts.color = "red" OR Parts.color = "green"); To check it, I'd like to look at every SID that will not be returned by t...

MySQL Update problem

$result=mysql_query(" UPDATE xxxxxx_users SET User_Password='$Password' WHERE FstName='$First' AND LstName='$Last'",$db) or die ("Password update successful!"); echo "Update failed, unknown user"; This correctly updates the db when the first and last names match and the db is not affected when they don't. My only issue is I always d...

How to install wordpress on MS SQL

I am trying to convert my wordpress site which is based on MYSQl to a MS SQL because my we have our main database through MS SQL and we are creating database driven wordpress sites. I have been able to automate all of our wordpress installation + setup through database sripts through MYSQL but all of our variables + inputs are in MS SQL...