Currently I have form with couple of fields and field for image. I have done with the part of field storing but don't know exactly how to store image path with PDO and can't find good tutorial. All I found was how to store image into DB instead of path. This is my code so far.
error_reporting(E_ALL);
ini_set('display_errors', 1);
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$id = null;
if ( !empty($_GET['id']))
{
$id = $_REQUEST['id'];
}
if ( null==$id )
{
echo "null==$id";
}
// keep track post values
$name = $_POST['name'];
$image = $_POST['image'];
$image_big = $_POST['image_big'];
$description = $_POST['description'];
// update data
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE meals set name = ?, image = ?, image_big = ?, description = ? WHERE id = ?";
$q = $pdo->prepare($sql);
$q->execute(array($name,$image,$image_big,$description,$id));
Database::disconnect();
echo "<code>Saved!</code>";
There is no problems with saving 'name' and 'description' fields.