Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created March 10, 2011 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/865087 to your computer and use it in GitHub Desktop.
Save walterdavis/865087 to your computer and use it in GitHub Desktop.
<?php
define('MYACTIVERECORD_CONNECTION_STR', 'mysql://yourDatabaseUserName:yourDatabasePassword@localhost/yourDatabaseName');
class Widgets extends MyActiveRecord {
//nothing else needed here
}
if(isset($_POST['id'])){
header('Content-type: text/html; charset=utf-8');
$id = str_replace('row_', '', $_POST['id']);
if($row = MyActiveRecord::FindById('widgets',$id)){
$row->$_POST['field'] = $_POST['value'];
$row->save();
print($row->h($_POST['field']));
}else{
print 'Error!';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment