mysql

What is the best practice to restrict off and on times in a database?

I have two fields in my database that simply store on and off times for my application. I need to make sure that the off time is not greater than the on time. I believe that a trigger may be good but I have never written one before. Can someone either verify that a trigger is the way to go or maybe writing some PHP code to handle this wo...

incremental backups on SQL Server and mysql

One user has said to me Applying incremental db backups is tedious, and a royal pain if you miss a step. I wouldn't bother with the approach on SQL Server or MySQL - that's what transaction logs are for, so you don't need to incorporate it into your data model So if i have transactions on mysql or sql server i can have ...

MySQL Query - Comparing rows with outside data

Ok, I have an array outside of the SQL database in the following format: $currStats['USERNAME'][SKILL NUMBER][1-3] Username obviously pertains to a specific user, skill number is the number of the skill and 1-3 is either XP, rank or level. So $currStats['Jimmy93'][0][1] would return the Overall (Skill #0) level of Jimmy93. Now, that ...

After I authenticate a user in API how should I make sure they don't have access for too long

I am working on builing an API and application section on a social network so it will be something like myspace, facebook, hi5, friendster, netlog, and many other's have application section, they all use a REST server method and most of them will issue a api key and secret to each application developed. The person who builds the app wil...

how can i open the '_mysql.pyd' in 'D:\Python25\Lib\site-packages'.

my ide is 'ulipad' and i open the file,it can't be Show,how can i get it. ...

Perl: Update Multiple Rows with one MySQL Call

Seems that it may not be possible, but hey I might as well ask, I could be wrong. Was wondering if there's anyway for perl to update multiple rows using one MySQL call, I'm using DBI. Any help or feedback would be greatly appreciated, this is possible in MSSQL through ASP and ASP.net so was wondering if also possible through perl on MyS...

Divs according to mysql result in a loop

First off, sorry if the title is confusing! I'm working on a part of a blog that determines how lists of recent posts (sometimes determined by a date) in a category are to be displayed. In the database, each category has a "type" set that determines whether the div it goes in is small or large. I can get the results to display but each ...

Get count of missing links in MediaWiki?

How can I get the number of missing links that are in my Wiki? We have a lot of articles about all kinds of things that haven't been written or stubbed yet, but we want to provide a progress bar so the community can see how close we are to being more complete. You can see the wiki here: http://worldeditor.org If you have any tips relat...

What do I need in a database for "Customers Who Bought This Item Also Bought"?

Amazon has "Customers Who Bought This Item Also Bought". I am wondering and want to add this to my shopping cart which I made. What fields do I need in a database? Any website, blog or resources for this? Can you suggest the mechanism how to I should code it please? ...

a sql question about linking tables

I wonder why these statements are not the same (the first one worked for me) AND user_thread_map.user_id = $user_id AND user_thread_map.thread_id = threads.id AND user_thread_map.user_id = users.id AND user_thread_map.thread_id = threads.id AND users.id = $user_id Shouldn't they be the same? In the 2nd one I linked all the tables in ...

What do I need to keep in a database to record the history of orders?

I want to keep customers' order history. I am thinking of keeping names of product, number of product ordered, price of product, date of order, name, address etc Table can be order_history and there will be field for id, date, cutomer_id,.. Then a question regarding names and number of products came in my mind. How should I keep them...

delete user best practice?

ive got a forum and i allow user to delete their account. and i want the users threads to still be there and the username to be shown, but i wonder one thing. if a user is deleted (basically i just NULL their username and password in the table row but i leave everything else intact) and another user is registering the same username, th...

MySQL stored procedure, handling multiple cursors and query results

How can I use two cursors in the same routine? If I remove the second cursor declaration and fetch loop everthing works fine. The routine is used for adding a friend in my webapp. It takes the id of the current user and the email of the friend we want to add as a friend, then it checks if the email has a corresponding user id and if no f...

get last record of a table

I have a form that lets users create new records, In the field that is the id that auto-increments i want the user to see the record number that this record is by somehow showing latest value+1 in the fields value. I was thinking of something like: <input type="text" value="<?php echo $myQuery['recordId'].length+1"/> But that doe...

How do I use the guid.comb strategy in a MySql db.

Is it possible to use the guid.comb strategy for identity generation with Mysql Db using Nhibernate? When I use it as mapping.Id(x => x.Id) .Column("row_guid") .CustomType(typeof(string)) .GeneratedBy.GuidComb() .Length(36); I end up with a ----> System.InvalidOperationException : Identi...

Help with SELECT statement

Hi, I have two tables: players and cards2 In each cards2 row, there is at least one player id (pid, pid2, pid3, pid4). I'm trying to come up with a select statement to get all fname's and lname's if there is more than one player id (pid's that are not 0). There is always a pid, but not always a pid2, pid3, etc. Does this make sense? He...

How to fetch all recordsets which are linked through that table?

I have three tables, with these fields: classes: class_id | name | grade classes_students: class_id | student_id students: student_id | name Classes has a 1:n relationship with Students, so one class can have many students. I want to select all students of a particular class, where class_id is 5. Could I just do something like thi...

date not saving in mysql database

I have a problem with saving a date in my mysql database. To test everything: I am trying to save 2010-01-01 (for example) in a mysql database. First i set my mysql field to date. This didn't work. But when i set the field to a string type it does save date in the database. Why doesn't it work when i want to save a date into a date fie...

Random results. Which way is faster SQL-query or a flat file?

I need to display some random data (1 row) from MySQL table and performance is very important for me. It doesn't necessarily has to be absolutely unique and super random data, so I have two options: 1) Query the database (my table has > 500 000 rows); 2) Automatically once a week create a flat text file (or php file with an array) from...

how can i lock tables in MySQL or phpmyadmin?

I need to use a table for a queuing system. The table will be constantly be updated. For example, multiple users on my website, will add their files for process, and I heard that when updates occur simultaneously from multiple users, the table becomes non responsive or something like that. so do I need locking tables in this situation...