Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Thursday, 9 July 2009

PDO lastInsertId issue

OK, so i may be dimmer than most, but I spent over an hour pulling my hair out over this.
To get the correct id back from PDO::lastInsertId(), you have to call it before the commit.
e.g. somthing like...

$dbh = new PDO();
$dbh->beginTransaction();
$stmt = $dbh->prepare($sql);
$stmt->execute($params);
$return = $dbh->lastInsertId();
$dbh->commit();


...will work nicely

Monday, 1 September 2008

Start and stop mysql on OSX

If you want to start MySql in Leopard, you need to call the startup item directly from the command line:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

And to stop it:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop