Alberto Viana
  • Home
  • About
KEEP IN TOUCH

Zend Framework and Oracle XMLType

Sep19
2011
Leave a Comment Written by Alberto

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

  • http://blogs.oracle.com/opal/entry/inserting_and_updating_oracle_1
  • http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html page 207
Posted in Oracle, PHP, Zend Framework - Tagged Oracle, oracle xmltype, PHP, Zend Framework
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Updating your pear on Ubuntu
» How to automated PHP 5.3 compatibility

No Comments Yet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Posts

  • Integração Contínua e PHP
  • How to automated PHP 5.3 compatibility
  • Zend Framework and Oracle XMLType
  • Updating your pear on Ubuntu
  • Billy Graham on Technology, Faith and Suffering

Categories

  • Continuous Integration
  • Development
    • Design Pattern
    • Oracle
    • PHP
      • CodeSniffer
      • Zend Framework
  • Presentations
  • Tecnology
  • Ubuntu

Tags

Apache Apache 2 billy graham Desenvolvimento Design Pattern Development faith Oracle Oracle XE oracle xmltype Padrão de Projeto pear PHP PHP5 PHP 5.3 phpcs PHP_CodeSniffer suffering tecnology Ubuntu xdebug Zend Framework

RSS Syndication

  • All posts
  • All comments

EvoLve theme by Theme4Press  •  Powered by WordPress Alberto Viana