PHP Array/record to PL/SQL

Discussion in 'Databases' started by aku345, Jul 19, 2011.

  1. #1
    Hello, I am creating PL/SQL to Insert a Php Array to a table..

    this is the sample of PHP Array:

    $array = array ( col1 => 'data one', col2 => 'data two', col3 => 'data three');
    PHP:
    this is the PL/pgSQL:

    create procedure insertData(data TypeTable) return booleas as
    Begin
          insert into table values(data);
    end;
    Code (markup):
    Table
    col1 character varying(50),
    col2 character varying(100),
    col3 character varying(200)
    
    Code (markup):
    TypeTable is a record data type that has the same field as "table".
    TypeTable = table = $array = (col1,col2,col3)

    I know that I can't parse Php Array to PL/SQL directly..

    So does anyone knows how to parse PHP Array to PL/SQL and insert the data to "table"?
     
    aku345, Jul 19, 2011 IP
  2. RamMurti

    RamMurti Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can use OCI8 function i.e. oci_bind_by_name.Format is as follows :
    bool oci_bind_by_name ( resource $statement , string $bv_name , mixed &$variable [, int $maxlength = -1 [, int $type = SQLT_CHR ]] )
     
    RamMurti, Feb 2, 2012 IP
  3. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    If it's an array to SQL and it has to be dynamic , why not something as 'this as key' as opposed to the exact array? A Simple PHP code underneath the vars that parses them the right way into SQL ?
     
    ezprint2008, Feb 5, 2012 IP