mysql

Convert a mysql date (datetime) into a better date format using php

I some php code which gets info from a mysql database. The problem is that the date is coming out in the format : 2010-02-03 22:21:26 Does anyone know a simple solution to make the date more user friendly format. e.g 2nd march 2010 at 22:21. Thanks ...

MySQL: What's the best to use, Unix TimeStamp Or DATETIME

Hello, Probably many coders want to ask this question. it is What's the adventages of each one of those MySQL time formats. and which one you will prefer to use it in your apps. For me i use Unix timestamp because maybe i find it easy to convert & order records with it, and also because i never tried the DATETIME thing. but anyways i'm...

How to convert this query to a "django model query" ?

Hello ! What i want is simple : models : class userLastTrophy(models.Model): user = models.ForeignKey(userInfo) platinum = models.IntegerField() gold = models.IntegerField() silver = models.IntegerField() bronze = models.IntegerField() level = models.IntegerField() rank = models.IntegerField() pe...

get an age from a D.O.B field

I need to calculate the age of a "customer" from their date of birth. have tried to use: DATEDIFF(year,customer.dob,"2010-01-01"); but it doesnt seem to like it. Any ideas, I KNOW its going to be something simple!? Thanks ...

How do i find out which script is inserting into mysql db without viewing a million files?

How do i find out which script is inserting into mysql db without viewing a million files? ...

PHP/MySQL Database Issues

PHP/MySQL newbie question. I have a database I've imported into my local phpmyadmin. However it seems I can't access it from my a php application. The connection string seems right and when I try to authenticate user credentials to access database information, no problems. However authenticate everyone and knows when I put in fake cred...

Does MySQL have an equivalent of SQL Server "indexed views"?

Does MySQL have an equalavent to SQL Servers "indexed view" functionality? http://stackoverflow.com/questions/439056/is-a-view-faster-than-a-simple-query What I'm specifically looking for is a way for MySQL to create a "view" that will return results faster than simply performing the underline view's query/sql. ...

array insert in db

Hi, How best to put the array (100 or more length) in the database (MySQL)? I do not want multiple access to the database because it is so loaded. So my solution is as follows: string insert = "INSERT INTO programs (name, id) VALUES "; for(int i = 0; i < name.Length; i++) { if (i != 0) { ...

Why my mysql DISTINCT doesn't work ?

Why the two query below return duplicate member_id and not the third? I need the second query to work with distinct. Anytime i run a GROUP BY, this query is incredibly slow and the resultset doesn't return the same value as distinct (the value is wrong). SELECT member_id, id FROM ( SELECT * FROM table1 ORDER BY created_at desc ) as...

Reversing column values in mysql command line

I have a table posts with the column published, which is either 0 (unpublished) or 1 (published). Say I want to make all the published posts into unpublished posts and all the unpublished posts into published posts. I know that running UPDATE posts SET published = '1' WHERE published = '0'; UPDATE posts SET published = '0' WHERE publi...

Need help displaying a dynamic table

I am designing a job rota planner for a company and need help displaying a dynamic table containing the staff details. I have the following tables in MySQL database: Staff, Event, and Job. The staff table holds staff details (staffed, name, address...etc), the Event table (eventide, eventName, Fromdate, Todate...etc) and the Job table ho...

How to implement Materialized View with MySQL?

How to implement Materialized Views? If not, how can I implement Materialized View with MySQL? Update: Would the following work? This doesn't occur in a transaction, is that a problem? DROP TABLE IF EXISTS `myDatabase`.`myMaterializedView`; CREATE TABLE `myDatabase`.`myMaterializedView` SELECT * from `myDatabase`.`myRegularView`; ...

mysql connector/net ssl shutsdown the server

Hello, when I try to connect my server throw connector/net using ssl with pfx certificate I had problem with establishing the connection. I get connection timeout. And the server probably fall down (I dont know it for sure, becouse I dont manage the server). On the Windows XP works all right, but on Windows 7 dont. Please, where is pro...

How to copy tables from one website to another with php?

I have 2 websites, lets say - example.com and example1.com example.com has a database fruits which has a table apple with 7000 records. I exported apple and tried to import it to example1.com but I'm always getting "MYSQL Server has gone away" error. I suspect this is due to some server side restriction. So, how can I copy the tabl...

DB structure for Twitter home/Facebook wall?

Basically a live feed of all your friends' recent posts. In a stupid sort of approach I think I'd start by building a query like: SELECT * FROM tblposts WHERE userid=friend_id_1OR userid=friend_id_2...... and so on Where friend_id_% is the userid of a friend from your friends list. But this must be a very inefficient way of doing it...

What is WordPress doing for content encoding in its MySQL database?

For some convoluted reasons best left behind us, I require direct access the contents of a WordPress database. I'm using MySQL 5.0.70-r1 on Gentoo with WordPress 2.6, and Perl 5.8.8 ftr. So, sometimes we get high-order characters in the blog, we have quite a few authors contributing too, for the most part these characters end up in Wor...

MySQL table doesn't update, can't find the error message

My knowledge level here is like zilch, but please bear with me. I have a site built in PHP/MySQL that uses the Smarty template engine. There's a registration form that, for some reason, isn't posting the data to the DB. Here's the function: $u = new H_User; $u->setFrom($p); $smarty->assign('user', $u); ...

Finding a users maximum score and the associated details

I have a table in which users store scores and other information about said score (for example notes on score, or time taken etc). I want a mysql query that finds each users personal best score and it's associated notes and time etc. What I have tried to use is something like this: SELECT *, MAX(score) FROM table GROUP BY (user) The p...

Form validation

Hi guys, I need to create a form that has many of the same fields, that have to be inserted into a database, but the problem I have is that if a user only fills in one or two of the rows, the form will still submit the blank data of the empty fields along with the one or two fields the user has filled in. How can I check for the rows t...

Looking for a good database structure to achieve Facebook/SO like notifications

I want to be able to have notifications on my site, similar to the way SO does it. I have looked for a good table structure to do this, but I cant seem to figure it out. I was thinking something like this. Notifications id, notification_type_id, user_id, type_id Notification Types id, notification_text Where the notification type w...