So few days ago I needed to insert Oracle XMLtype with Zend Framework. I used oracle adapter to wrote it in Zend Framework. I was looking for and I found on Chris Jones Blog.
Database
-- Table definition is: create table xwarehouses (warehouse_id number, warehouse_spec xmltype);
Insert with Zend Framework
<?php
class App_Xml extends Zend_Db_Table_Abstract
{
public function insertXML()
{
// XML data to be inserted
$xml =<<<EOF
<?xml version="1.0"?>
<Warehouse>
<WarehouseId>1</WarehouseId>
<WarehouseName>Southlake, Texas</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
EOF;
$id = 1;
$stmt = $this->_db->prepare("insert into xwarehouses (warehouse_id, warehouse_spec)
values ({$id}, XMLType(:clob))");
$lob = oci_new_descriptor($this->getAdapter()->getConnection(), OCI_D_LOB);
$stmt->bindParam(':clob', $lob, OCI_B_CLOB, -1);
$lob->writeTemporary($xml);
$stmt->execute();
$lob->close();
}
}
Reference
