020 555 1111
  • Old fashion, modular, procedural PHP plus some scaffolding techniques to allow it to mimic MVC simplicity.
  • A quick reference to help you find in PHP maze what needs to be done and how to do it.
  • Learn a PHP Object Oriented Programming by building a live discussion forum application.
  • MVC - Model View Controller - real life, easy reference and application.
This product has options, take a look at them and select ones you like the most.
Options are displayed under image section.

[MySQL PDO Const]

PDO::PARAM_LOB (integer)

Represents the SQL large object data type. 

Used with:

  • PDOStatement::bindColumn
  • PDOStatement::bindParam
  • PDOStatement::bindValue
//$value_assigned_to_placeholder - large data object - see: notes below
$sth->bindValue(':named_paceholder', $value_assigned_to_placeholder, PDO::PARAM_LOB)


Large Objects (LOB / BLOB) 

At some point in your application, you might find that you need to store "large" data in your database.
Large typically means "around 4kb or more", although some databases can happily handle up to 32kb before data becomes "large".
Large objects can be either textual or binary in nature. 


  • image (media in general)
  • very long text
  • piece of code, e.g. html, css or other etc.

Displaying image stored in DB

LOB is usually big, you may consider streaming it to browser, instead of sending it as one big chunk.
With streaming / file reading methods some familiar PHP file handling functions can come handy:

fpassthru() php.net w3cshools
fgets() php.net w3cshools
fread()  php.net w3cshools
stream_get_contents()  php.net w3cshools


$dbh = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD);
$stmt = $db->prepare("select mime, file from images where id=?");
$stmt->bindColumn(1, $mime, PDO::PARAM_STR, 256);
$stmt->bindColumn(2, $file, PDO::PARAM_LOB);

header("Content-Type: $mime");

Store image into database

$dbh = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD);
$stmt = $db->prepare("insert into images (id, contenttype, imagedata) values (?, ?, ?)");
$id = get_new_id(); // some function to allocate a new ID

// We are uploading file using form
$fp = fopen($_FILES['file']['tmp_name'], 'rb');

$stmt->bindParam(1, $id);
$stmt->bindParam(2, $_FILES['file']['type']);
$stmt->bindParam(3, $fp, PDO::PARAM_LOB);