SQL

Problem adding column values in MySQL SELECT query / sorting by added column values

I wanted to sort an sql query according to added column values. Like this

<?php
$query
= "SELECT * FROM myTable1 AS my1 ".
"LEFT JOIN myTable2 AS my2 ON my2.id = my1.id ".
"LEFT JOIN myTable3 AS my3 ON my3.id = my1.id ".
"ORDER BY (my2.price + my3.price)";
?>

Search and replace for characters in the whole database for Drupal

<?php
# Define which characters you want changed (key) and what you want them changed to (value)
$charChangeArray = array(
'Ã¥'=>'å',
'Ã…'=>'Å',
'ö'=>'ö',
'Ö'=>'Ö',
'ä'=>'ä',
'Ä'=>'Ä',
'ç'=>'ç',
'é'=>'é',
'¿½'=>'è',
'â'=>'â',

A script for converting your MySQL database collation to utf8 and utf8_general_ci and table columns to uf8_bin in Drupal

I recently had to migrate a database from one server to another. The new server was MySQL 5.xxx and I got the chance to change the collation and character set of my database. Being of Swedish origin there's always a hassle with å,ä,ö letters.

Checking elements in an array, vector, in PHP against entries, column values, in a MySQL table

Basically what I wanted to do was to check if all the elements in the array was in the MySQL table and if so update it and if it not existed enter the values into the table.

The table consisted of two columns id and frequency. The procedure would be update - Add one to frequency, insert - Add new id and set frequency to one.

Now I could do this with a foreach statement and probing the table for each element but as the array/vector was quite large that would mean a lot of SELECTS and calls to the database which didn't sound very efficient to me.

urchinTracker(); // -->