mysql

Store IPv6 in database

What's the best practise to store IP's with PHP in MySQL database? There's a function called ip2long - but this is just for IPv4. But what about IPv6? I know a php function that is for IPv6 IP's, but it doesn't work on Windows with PHP < Version 5.3 ...

help in forming mysql query to find free(available) venues/resources for a give date range

I have tables & data like this: venues table contains : id +----+---------+ | id | name | +----+---------+ | 1 | venue 1 | | 2 | venue 2 | --------------- event_dates : id, event_id, event_from_datetime, event_to_datetime, venue_id +----+----------+---------------------+---------------------+----------+ | id | event_id | event_fr...

PHP mysqli::autocommit VS "START TRANSACTION"

In our database layer object, we have always managed transactions with "START TRANSACTION", "ROLLBACK" and "COMMIT" SQL statements executed via mysqli::query. Doing some research today, I discovered this mention in the MySQL Manual regarding using API level calls to manage a transaction VS using straight SQL: Important Many API...

With VBA, find the version of the the MySQL ODBC driver installed in Windows

Using Visual Basic for Applications, how can I find out which version of the MySQL ODBC driver is installed in Windows on a user's machine? I have a Microsoft Access application that uses the MySQL ODBC driver to make a connection. The connection string looks like this: ODBC;DATABASE=mydatabase;DRIVER={MySQL ODBC 3.51 Driver}; OPT...

how to delete mysql database through shell command

I use the pylons and sqlalchemy. I constantly update the schema files and delete the old db content (means db itself) and recreate the database so that new schema shall take place. Every time I do this by opening the MySql Query Browser and login & delete the database/schema. How to delete the mysql db/schema thorough linux shell comma...

Difference between value = ""; and value = NULL; in PHP ?

What is the difference between value = NULL; and value = ""; in PHP ? Am facing wierd response as if I set value = ""; than I get empty array response from database which is what am supposed to get but if I set value = NULL; than I get empty string response from mysql database instead of empty array response. I am not sure why this ...

php cookies,sessions,mysql

I wound up inheriting a site which seems like it was originally designed to provide access to registered users then decided it wanted public access with the exception of specific restricted features. The access control is decent, however, what's boggling my mind is why anyone would add an entry to their database for each unique visitor....

latest visitors

Say you want to display the latest visitors on a users profile page. How would you structure this? Perhaps a table called uservisitors: userid (the user that gets a visit) visitorid (the visitor) time And how would you select this with mysql? Without any duplicates, What I mean is if User 1 visits user 2's profile, then 5min later v...

How to deliberately lock a MySQL row such that even SELECT will return an error?

I'm trying to use MySQL row locking to basically emulate a MuteEx on a row. Lets say that my table has 2 columns, an id and a text field, and three entries (1,a) (2,b) and (3,c). SELECT * FROM table; would return these results. I can lock a specific row the normal way. START TRANSACTION; BEGIN; SELECT * FROM table WHERE id = '2' FOR UPD...

Column type of 'set' and Rails

I am building a database of online offers. Each offer can be viewed in one or more countries, for instance an advertiser may be interested in reaching offers in the US & Canada. The list of countries we are covering is about 50 long with each country identified with an ISO standard two letter acronym like US, CA, GB, FR, DE, etc. I cou...

Separate dbx connection to a thread

I made a small app that connects to a mysql db using dbx. It works ok with my local mysql server, but it's supposed to work with a remote server. Connecting to the remote server takes a few seconds, which freezes the app. So my question is, how can I put the connection code in a different thread? I'll have to pass that connection to t...

How do I handle duplicate entries in a single column database?

A user may enter keywords into a text field and separate the keys using comma. So the input may be bananas, apple, orange, pineapple. In my database, I have a table called keyword, and it has only one column keyword which also is the primary key. I add the keywords to the database, by $myArray = expload(',', $keywords). Then I loop thr...

MySQL Orderby a number, Nulls last

Hi, Currently I am doing a very basic OrderBy in my statement. SELECT * FROM tablename WHERE visible=1 ORDER BY position ASC, id DESC The problem with this is that NULL entries for 'position' are treated as 0. Therefore all entries with position as NULL appear before those with 1,2,3,4. eg: NULL, NULL, NULL, 1, 2, 3, 4 Is there a w...

How to integrate Visual FoxPro w/ MySQL for eCommerce website?

Hi all, I'm working on an eCommerce website for a small merchant. This merchant uses Opera (which is based on Visual FoxPro) to manage his in-store inventory, and would like the online store inventory to reflect the in-store inventory. I'm guessing that my first step is to set up a way to regularly transfer the information from the VF...

MySQL Static Hash-index

Is there any way to prespecify the size of a hash index during the initial table creation. If I know that I may eventually have 200 million unique keys and I don't want to to come to a halt resizing at 100 million can the size be prespecified. Do any other free databases support presized hash tables? ...

dynamically change mysqli connection timeout in PHP

Hi, how can I dynamically change MySqli connection timeout using PHP? I found the following manual that you can set an option after a connection is opened, but it says it only support Windows since PHP 5.3.1: http://www.php.net/manual/en/mysqli.options.php I'm using PHP5.2.4, MySQLi (improved version) the default connection timeout is...

MySQL Orderby a number, Empty Strings (or 0's) Last

Hi, Just asked a question pretty similar to this one... Currently I am doing a very basic OrderBy in my statement. SELECT * FROM tablename WHERE visible=1 ORDER BY position ASC, id DESC The problem with this is that empty string entries for 'position' are treated as 0. Therefore all entries with position as empty string appear befor...

Single SQL query on many to many relationship

I have a simple database with few tables (and some sample columns): Posts (ID, Title, Content) Categories (ID, Title) PostCategories (ID, ID_Post, ID_Category) Is there a way to create single SQL query which will return posts with categories that are assigned to each post? ...

Reading reliably from a constantly appended-to table

I've got a web application, one of whose functions is which is constantly appending rows to a large table. The rows look approximately like this: id bigint not null primary key visited datetime not null ip_address # Other fields It's a tracking table, as you've probably guessed. The use of this table is completely append-only, that i...

Sort MySQL in Human

here's the code: $sql_namesResult = mysql_query("SELECT name FROM `scrimaprovedlist` ORDER BY `scrimaprovedlist`.`eorank`"); eo rank is a NUMERICAL value for a rank (general, colonel, ect). The problem is, when i set myself for 1, i am the top, but comes rank 10, instead of rank 2. how do i edit this to make it show in order: 1 2 ...