mysql

What the best way to access the databse inside a class in PHP?

I have a session class that needs to store session information in a MySQL database. Obviously I will need to query the database in the methods of this class. In general I may need to connect more than one database simultaneously and may or may not be connected to that database already. Given that, what's the best way to access datab...

MySqlCommand Parameter not Working

In the following code, used to get a list of products in a particular line, the command only returns results when I hard code (concatenate) productLine into the SQL. The parameter substitution never happens. + "lineName = '@productLine' " + "and isVisible = 1 "; MySqlDataAdapter ad...

Re-installing MYSQL(windows) - How to get to the old data with the new install?

I needed to re-install my computer but I didn't think about exporting the data from mysql 5. How do I get the data from the old installation into the new installation, is this just copying the data directory or do I have to take other steps to get to the data? ...

make an ID in a mysql table auto_increment (after the fact)

I acquired a database from another developer. He didn't use auto_incrementers on any tables. They all have primary key ID's, but he did all the incrementing manually, in code. Can I turn those into Auto_incrementers now? ...

java.sql.Connection extension for SSH

I have a MySQL database behind a firewall which can only be accessed via an SSH connection. Does anyone know of an implementation of java.sql.Connection which would allow me to make an SSH connection to this database? ...

How do I upgrade mysql?

When upgrading MySQL, I first create a backup of the database. Then I will uninstall the current version installed, and delete all the files that were left by the installer. Then I install the latest GA version, and restore the created back-up, using the MySQL Administrator. Is there a better way of doing an upgrade of the MySQL. Becaus...

not a valid mysql resource

Hello, I am trying the following code: <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $query = "SELECT * FROM Auctions"; $result = mysql_query($query); while($row = mysql_fetch_array($result, ...

displaying mysql records in php incorrectly

Hello, I have the following code: <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db(ebay); $query = "SELECT * FROM Auctions"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array(...

Do numerical primary keys of deleted records in a database get reused for future new records?

For example if I have an auto-numbered field, I add new records without specifying this field and let DB engine to pick it for me. So, will it pick the number of the deleted record? If yes, when? // SQL Server, MySQL. // Follow-up question: What happens when DB engine runs out of numbers to use for primary keys? ...

MySQL Joins

My table structure looks like this: tbl.users tbl.issues +--------+-----------+ +---------+------------+-----------+ | userid | real_name | | issueid | assignedid | creatorid | +--------+-----------+ +---------+------------+-----------+ | 1 | test_1 | | 1 | 1 | 1 | | 2...

Is there a clean way of cleaning up duplicate entries in MySQL?

In a table, I have three columns - id, name, and count. A good number of name columns are identical (due to the lack of a UNIQUE early on) and I want to fix this. However, the id column is used by other (4 or 5, I think - I would have to check the docs) tables to look up the name and just removing them would break things. So is there a g...

Storing Social Security Numbers

The HR department at the company that I am currently working for has requested that I provide a system for storing employee social security numbers in our company database. The reason for this is to streamline payroll completion, as we use in-house software for employee timesheets but have to integrate with third-party software for our a...

Why don't more .NET applications use MySQL or a DAO that allows for the use of MySQL?

I suppose this question could just as easily be applied to PHP with regard to MSSQL. However, with some versions of MSSQL being so expensive, I always wondered, what is the real advantage of choosing it over MySQL for .NET development? Is it really difficult to use .NET tools in conjunction with a MySQL database? Why not create some sort...

mysql charset cli

how do i determine what a mysql db's charset is set to? in the cli? ...

Mysql Offset Infinite rows

I would like to construct a query that displays all the results in a table, but is offset by 5 from the start of the table. As far as I can tell, MySQL's LIMIT requires a limit as well as an offset. Is there any way to do this? ...

Should I use a single or multiple database setup for a multi-client application?

Hi everyone, I am working on a PHP application that intends to ease company workflow and project management, let's say something like Basecamp and GoPlan. I am not sure on what the best approach is, database-wise. Should I use a single database and add client-specific columns to each of the tables, or should I create a database for eac...

How to synchronize development and production database.

Do you know any applications to synchronize two databases - during development sometimes it's required to add one or two table rows or new table or column. Usually I write every sql statement in some file and during uploading path I evecute those lines on my production database (earlier backing it up). I work with mySQL and postreSQL da...

Functions in mysql or php

Is it generally better to run functions on the webserver, or in the database? eg: INSERT INTO example (hash) VALUE (MD5('hello')) or INSERT INTO example (hash) VALUE ('5d41402abc4b2a76b9719d911017c592') Ok so that's a really trivial example, but for scalability when a site grows to multiple websites or database servers, where is it b...

MySql cluster "split brain" solution?

Before few days I was at some IT conference here in Belgrade. On Agenda was a topic about MySql, and clustering in MySql, and the guys from MySql said that they have the best solution for cluster split brain problem, does anyone know something about this, is this true or just a marketing trick? ...

What is the best way to calculate page hits per day in MySQL

On my blog, I display in the right nav the 10 most popular articles in terms of page hits. Here's how I get that: SELECT * FROM entries WHERE is_published = 1 ORDER BY hits DESC, created DESC LIMIT 10 What I would like to do is show the top 10 in terms of page hits per day. I'm using MySQL. Is there a way I can do this in the database...