mysql

Warning: Division by zero in....

Hi. Ive been programming a search form with three fields, and the one thatt is giving me troubles is the one that use "LIKE" clause in sql. Here is the code: <form method="post" action="<?php $_SERVER['PHP_SELF']?>"> <p> <label for="nome">Nome Empresa:</label> <input type="text" name...

Badge system and storing conditions as variables?

I'm trying to write a piece of code that checks a users stats, be that their points, rank or num_friends and in turn awards them a badge similar to that used in SO. The system is set so when a task (vote up, comment, etc.) is completed by a user, their user_id is recorded and queued to be evaluated at 5 min intervals by a cron job. Is ...

MySQL current_insert_id()? (Not last_insert_id())

Hi All, I am inserting a row with a char column for a hash based on (among other things) the row's auto id. I know I can insert it, fetch the insert_id, calculate the hash, and update it. Does anyone know of a way to do this in a single query? You would need the rows insert_id at the time of insert. Is that completely impossible, ...

Two tutorials on storing images in a database... which technique is better?

I'm implementing a website where images are stored in a database. These are two tutorials that I've come across with two different ways of storing and retrieving image data. Which one would you recommend, and why? http://www.developertutorials.com/tutorials/php/storing-images-database-050620/page1.html http://www.onlamp.com/pub/a/on...

Identifying Missing Matches in a Mysql DB

Is there a way to identify missing combination in a join table. eg: Three tabes animals food animals_food can identify wether any particular food hasn't been associated with an animal, or vice versa? ...

Using named parameters with MySQL .NET Provider

In the MySQL .NET provider, you can use named parameters in the syntax: ?parametername Now, I'm trying to create a named parameter for a parameter that will be used in an 'IN' list, e.g. : select * from mytable where id in (?ids) How can I use a named parameter with this, if I use varchar, it will add quotes before and after the li...

mysql proxy socks

Plain and simple, can anyone explain me how to connect to a mysql server through a proxy (socks4/5). Preferable via the mysql command line (although there are no options for that in the client). If it's not possible through the mysql command line than ANY other method will work. Thank you. ...

Create an ActiveRecord database table with no :id column?

Is it possible for me to create and use a database table that contains no :id column in ActiveRecord, Ruby on Rails. I don't merely want to ignore the id column, but I wish it to be absolutely non-existent. Table Example :key_column :value_column 0cc175b9c0f1b6a831c399e269772661 0cc175b9c0f1b6a831c399e26977...

Ruby on Rails, ActiveRecord, Binary search.

If I had the following table. create_table :my_table, :id => false do |t| t.string :key_column t.string :value_column end How would I ensure that the rows are optimaly stored for binary search by the field of :key? And how would I make sure binary search is used? ...

Extending classes in the database

I am working on a php project that needs to store information about various buildings and will store different types of information depending on the type of the building: Class Building { var $location var $name } The Building class will be extended by classes like, House and Office so the classes will look like this (just an ...

How to select the last 24 hours of rows from a row offset

Im trying to compute a 24 hour rms (root mean squared) from a dataset stored in MySQL. I Need to grab the last 24 hours of points that occur within 24 hour period before a particular row offset. For instance if I wanted to compute 24hour rms for row id 1250 which has a timestamp of June 7th 2007 at midnight I would need to get all the po...

Storing reader information in C#

Hi, I know what I asking might not make a lot of sense for C# experts but I'll explain what I want to do and then you can suggest me how to do it in a better way if you want ok? I have a C# class called DatabaseManager that deals with different MySQL queries (ado.net NET connector, not linq or any kind of ActiveRecord-ish library). I ...

Best practice for hierarchical MySQL asset tracking

Hi, I'm writing an online project asset tracker but I'm new to MySQL. What would be the best way of tracking projects, users, and assets for something like this? I have 3 tables for assets, users, and projects. Users should own projects and assets. Assets could be members of multiple projects, and projects should be able to be seen by mu...

MySQL speed optimization on a table with many rows : what is the best way to handle it ?

Hi, I'm developping a chat application. I want to keep everything logged into a table (i.e. "who said what and when"). I hope that in a near future I'll have thousands of rows. I was wondering : what is the best way to optimize the table, knowing that I'll do often rows insertion and sometimes group reading (i.e. showing an entire conver...

How to convert date in Text box to MySQL DATETIME format

Hi, I'm quite new to php and have been reading Larry Ullman book to develop a basic db site. I have used the YUI Calendar pop up date picker to add a date to a text field called"date". The date format it enters is eg Thursday, 7 May 2009 I have tried many different ways to try and enter the date in to mysql db but it remains at 00 00 00...

Linking Facebook Connect

Hello guys, I've started working on integrated Facebook Connect with my app. I have a slight lack of knowledge problem though. I can perfectly make it so you log into Facebook Connect on my site, etc, shows your details all FB Connect functions work. But, how do I make it so I can store the facebook user ID into my MySQL database as pa...

How to check if a date has passed

I am trying to check if a date has passed or if it is the future. If the end_date has passed then I do not want it to display. end_date is a MySQL timestamp. Right now all news articles are displaying even if their end_date has passed. Here is the code I am using to check if the date has passed: function dateExp( $timestamp ){ $exp ...

How best to compare to 0 in PHP?

In one bit of code I'm working on, I need to pull a value from the database and check if it is 0. Originally, I had written this as: if ($myVal == 0) { ... But when I looked at it again today, I realised a bug there: var_dump("foo" == 0); // bool(true) // and while we're here... var_dump(intval("foo")); // int(0) Since this value...

Eclipse/MySQL integration plugins?

What plugins should I install in Eclipse to integrate MySQL into Eclipse so that I can, for example, create and modify tables inside Eclipse? ...

mysql performance

We are developing our database in MySql with innoDB engine. The database contains a column that is of varchar type with each entry containing about 3000 characters. We are to provide search on this column. For speeding up purpose, we need to add index on this column. Can you put in some information in this regard? Which type of index do...