mysql

Got error 122 from storage engine

Got this from some mysql queries, puzzled since error 122 is usually a 'out of space' error but there's plenty of space left on the server... any ideas? ...

Terminate MySQL connections on shared host?

I'm using MediaTemple's Grid Server (shared/grid hosting) to run some MySQL/PHP sites I'm writing and noticed that I wasn't closing one of my MySQL connections, which caused my site to error out, "Too Many Connections". I can't log in anywhere to close the connections manually. Is that any way to close open connections using a script ...

MySQL, Asterisk Dialplans and call forwarding

How do I get Asterisk to forward incoming calls based on matching the incoming call number with a number to forward to? Both numbers are stored in a MySQL database. ...

Python Psycopg error and connection handling (v MySQLdb)

Another crack at this: I have a frequent problem with python's psycopg2, perhaps in 2 parts. First, I consistently screw up string assignment, if anyone can lobotomize line 5 below for me, much appreciated (The first answer does work with 1 value.) Second, when I try to add a long sequence to a table, something like string-number pair i...

What is the best way to access a database from PHP?

Hi, When accessing a MySQL-database from PHP there seems to be several ways: Sprinkle the code with raw SQL-statements Use the VO-pattern from Java (e.g. DB_DataObjects from PEAR) DIY and write a script that auto-generates one PHP class per database table Apart from this I have also read about LINQ in .NET but have not s...

MySQL Data Truncation Error

I'm working with a fairly simple database, from a Java application. We're trying to insert about 200k of text at a time, using the standard JDBC mysql adapter. We intermittently get a com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column error. The column type is longtext, and database collation is UTF-8. Th...

How do I check to see if a value is an integer in MySQL?

I see that within MySQL there are Cast() and Convert() functions to create integers from values, but is there any way to check to see if a value is an integer? Something like is_int() in PHP is what I am looking for. Thanks! Craig ...

What is the most straightforward way to pad empty dates in sql results (on either mysql or perl end)?

I'm building a quick csv from a mysql table with a query like: select DATE(date),count(date) from table group by DATE(date) order by date asc; and just dumping them to a file in perl over a: while(my($date,$sum) = $sth->fetchrow) { print CSV "$date,$sum\n" } There are date gaps in the data, though: | 2008-08-05 | 4 |...

How can MyISAM tables be used more safely?

I like InnoDB's safety, consistency, and self-checking. But I need MyISAM's speed and light weight. How can I make MyISAM less prone to corruption due to crashes, bad data, etc.? It takes forever to go through a check (either CHECK TABLE or myisamchk). I'm not asking for transactional security -- that's what InnoDB is for. But I do w...

How do I pass a variable to a mysql script?

I know that with mysql you can write SQL statements into a .sql file and run the file from the mysql command line like this: mysql> source script.sql How do I pass a variable to the script? For example, if I want to run a script that retrieves all the employees in a department, I want to be able to pass in the number of the department...

Using MySQL with Entity Framework

Can't find anything relevant about Entity Framework/MySQL on Google so I'm hoping someone knows about it. ...

Fetch unread messages, by user

I want to maintain a list of global messages that will be displayed to all users of a web app. I want each user to be able to mark these messages as read individually. I've created 2 tables; messages (id, body) and messages_read (user_id, message_id). Can you provide an sql statement that selects the unread messages for a single user? O...

What is the best way to handle sessions for a PHP site on multiple hosts?

PHP stores its session information on the file system of the host of the server establishing that session. In a multiple-host PHP environment, where load is unintelligently distributed amongst each host, PHP session variables are not available to each request (unless by chance the request is assigned to the same host -- assume we have n...

Scaling cheaply: MySQL and MS SQL

How cheap can MySQL be compared to MS SQL when you have tons of data (and joins/search)? Consider a site like stackoverflow full of Q&As already and after getting dugg. My ASP.NET sites are currently on SQL Server Express so I don't have any idea how cost compares in the long run. Although after a quick research, I'm starting to envy ...

mysqli_statement::num_rows() returns the wrong value

I was writing a database handler class in PHP using the mysqli class and prepared statements. I was attempting to print out the result. It didn't work right off the bat so I decided to do some debugging. I tried to use the num_rows() method from the mysqli_statement class, but it kept returning 0. I decided to write a small porti...

Zend Framework Select Operator Precedence

Hi everyone, I am trying to use Zend_Db_Select to write a select query that looks somewhat like this: SELECT * FROM bar WHERE a = 1 AND (b = 2 OR b = 3) However, when using a combination of where() and orWhere(), it seems impossible to use condition grouping like the above. Are there any native ways in Zend Framework to achieve the ...

Spelling Alternatives based on a Database?

I'm looking for an efficient way (using PHP with a Mysql Database) to suggest alternative spelling for a query. I know I can use services such as Yahoo's Spelling Suggestion but I want the suggestions to be based on what is currently available in the database. For example: The user has to fill a form with a "City" field, and I want to...

MDB2 disconnects and forgets charset setting when reconnecting

We recently debugged a strange bug. A solution was found, but the solution is not entirely satisfactory. We use IntSmarty to localize our website, and store the localized strings in a database using our own wrapper. In its destructor, IntSmarty saves any new strings that it might have, resulting in a database call. We use a Singleton ...

How to timeout a mysql++ query in c++

I am using mysql++ in order to connect to a MySQL database to perform a bunch of data queries. Due to the fact that the tables I am reading from are constantly being written to, and that I need a consistent view of the data, I lock the tables first. However, MySQL has no concept of 'NOWAIT' in its lock query, thus if the tables are locke...

Easy way to export a SQL table without access to the server or phpMyADMIN

I need a way to easily export and then import data in a MySQL table from a remote server to my home server. I don't have direct access to the server, and no utilities such as phpMyAdmin are installed. I do, however, have the ability to put PHP scripts on the server. How do I get at the data? I ask this question purely to record my way ...