mysql

Is there a way to return the id of a row that was just created in MySQL with PHP?

When I create a new entry in my MySQL database, I'd like the query to return the id of the table that was just created. If it cannot do this, is there another way to find out the this id? The reason I want to do this is so I can link a new row to the row that spawned it (and there's no guarantee that they're consecutive) ...

Why isn't my MySQL database insertion working?

$author = $_SESSION['username']; $subject = $_POST['subject']; $body = $_POST['body']; $branched = $_POST['branched']; $time = time(); $branchedFrom = $_POST['parent']; $id = $_POST['parent']; $next = 0; $previous = 0; $branchedTo = 0; mysql_query("INSERT INTO offtopic VALUES('', '$author', '$subject', '$body', '$time', '$next', '$pre...

Application to reverse engineer MySQL & PostgreSQL DB?

Is there an application to reverse engineer an existing database in mysql and/or postgre? I'm interested in obtaining the DB diagram from an existing one, similar as it can be done in MSSQL Server ...

django saving modelform with MultipleChoiceField

I'm using MySQL my table model : class Offer(models.Model): ... additional=models.CharField('Dodatkowe informacje',max_length="100",choices=ADDITIONAL_CHOICES.items(),blank=True) ... my form: class OfferForm(forms.ModelForm): additional=forms.MultipleChoiceField(label='dodatkowe informacje',choices=ADDITIONAL_CHOICES....

Is there a way to set variables in ssh?

Still working my way around this, but is there any function/command I can use to set some simple variables? Logging into mysql is quicker when I'm already ssh'd in, but typing in the full connection string is a bit annoying. Any way to do something like: mysql ${variable} dbname Where variable would be something like -u user -p -h ho...

Remote mysql connection

Hi, I'd been making a web on localhost and when I tried to move it on host it shows me lots of errors. Seems like it can't connect to my local database. Here's the code: $host = "myip"; $user = "root"; $pass = ""; $db = "mydatabase"; mysql_connect($host, $user, $pass); mysql_select_db($db); $on = mysql_fetch_row(mysql_query("SELECT COU...

How do I update MySQL row in PHP?

I have a MySQL database that I'm working with, but when I try to update a row in it, it doesn't work. Here's the update code I'm working with: mysql_query("UPDATE offtopic SET next = '$insert' WHERE id = '$id'"); ...

Best technique for caching results from queries that change infrequently

I have a php web application where certain data changes on a weekly basis but is read very frequently often. The SQL queries that retrieve the data and the php code for html output are fairly complex. There are multiple table joins, and numerous calculations - but they result in a fairly basic html table. Users are grouped, and the ta...

.Net ORM that works well with MySQL

My C# Windows Service ( It's a service, not a MVC web application!) needs to talk to MYSQL database. In order to ease my data layer effort I am thinking about using an ORM for this purpose. So which .Net ORM works most well with MYSQL database? NHibernate? Subsonic? Entity Framework (haha)? LINQ2SQL( no, this can't be the choice, can it...

technology behind vimeo.com

Hey does anybody know technologies that vimeo uses? I know they use mysql for the db, not sure if they use memcache. The site seems pretty smooth compared to youtube. Thanks ...

mysql_connect() on localhost

I am trying to implement a little 'intranet' on my home network, but I am an apache/mysql configuration noob... Running fedora 10, and have apache, mysql, and php set up as well as i know how. However, when I try using a standard form with POST, the php script seems to error out on the mysql_connect(...); line. I don't get an error me...

MySQL Query, bulk insertion

I have a bulk data for insertion in MYSQL Tables, let use suppose, 10k in one time, What I am doing is store the data in an XML file and then go for insertion (data is around 50K rows), It will take a lot of time, Is there any option for bulk insertion in MySQL tables. Thanks in advance, Please help. ...

howto Communicate with MYSQL Embedded Server from MySQL++ DLL?

I have write my code using MySQL++ to communicate with the MySQL Embedded Server. at first, I used dynamic link method (use mysqlpp.dll), but it always fail with 1 when do mysql_real_connect(). later i realized that i should not use dll, so i go to use static link method (use mysqlpp.lib) and things goes ok. I think maybe mysql++ can ad...

How to delete Duplicates in MySQL table.

I've given a client the following query to delete duplicate phone no. records in an MSSQL database, but now they need to also do it on MySQL, and they report that MySQL complains about the format of the query. I've included the setup of a test table with duplicates for my code sample, but the actual delete query is what counts. I'm aski...

How to Maintain Foreign Key Constraint Across Different Databases?

I know, I know, putting two related tables on different databases isn't exactly the best design practice. But for whatever's sake, suppose that I have to do it absolutely. And I have to break up two foreign-key-related tables that were previously located in a database into two databases, that are located on two different servers, but I s...

How to find the *position* of a single record in a limited, arbitrarily ordered record set?

MySQL Suppose you want to retrieve just a single record by some id, but you want to know what its position would have been if you'd encountered it in a large ordered set. Case in point is a photo gallery. You land on a single photo, but the system must know what its offset is in the entire gallery. I suppose I could use custom indexin...

Ruby: Mysql timestamp/datetime problem

Is there solution for '0000-00-00 00:00:00' problem, without changing table? I have "[]" in this query: dbh.select_all("select j.n, j.name, j.dsc, j.flag, j.td from job j where j.td='0000-00-00 00:00:00'") I look solution for this: http://rubyforge.org/tracker/index.php?func=detail&aid=22243&group_id=234&atid=967 ...

SQL_CALC_FOUND_ROWS / FOUND_ROWS() does not work in PHP

I use SQL_CALC_FOUND_ROWS in Mysql SELECT statement, to get the number of lines my SELECT would return without a LIMIT clause. $sql = new mysqli('localhost', 'root', ''); $sql->select_db('mysql'); $s1 = $sql->query('select SQL_CALC_FOUND_ROWS * from db limit 0, 3'); $s2 = $sql->query('select FOUND_ROWS()'); if($row = $s2->fetch_row()) p...

Select columns across different databases

Is it possible to do a select ( or insert) statement across different databases that are located on the same server? If yes, how? ...

diffing two databases

Is there a tool to find the difference between two databases. Both the schema and the actual data are pretty much the same, but not 100%. Do you know a tool that can help to succinctly describe the changes. ...