Hi all,

actually working with ZF1.5 PR
I'm facing about a simple trouble : I need to capture the content of a binary 
field from a postgresql db.

with pdo there no trouble if you use the good param for column
Working code with pdo croquis is a bytea field

$str_dsn = 'pgsql:host=127.0.0.1;port=5432;dbname=sample';
try {
   $dbh = new PDO($str_dsn, $user='sample', $pass='sosimple');
} catch (PDOException $e) {
   print "Error No connexion !: " . $e->getMessage() . "<br />";
   die();
}
try{
   $cpt=1;
        $stmt = $dbh->prepare("SELECT no_point,croquis from \"Vue_PFP\" WHERE 
no_point=? limit 1");
        if ($stmt->execute(array('16220197'))) {
                $stmt->bindColumn(1, $no_point, PDO::PARAM_STR, 256);
                $stmt->bindColumn(2, $croquis, PDO::PARAM_LOB);
                $stmt->fetch(PDO::FETCH_BOUND);
                        fpassthru($croquis);
                        $cpt++;
        }
   $dbh = null;
} catch (PDOException $e) {
   print "Error!: " . $e->getMessage() . "<br />";
   die();
}

Now I want the same in ZF but only obtain a ressource id ...

        $this->_pt_num = '16065420';
        // First we check we have always the db object from registry
                if ( (Zend_Registry::isRegistered('db')) &&  ( 
Zend_Registry::get('db') instanceof Zend_Db_Adapter_Abstract) ) {
                        $this->_db = Zend_Registry::get('db');
                }else{
                        throw new Zend_Exception('db object does not implement 
Zend_Db_Adapter_Abstract');
                }
        try{
                $select = $this->_db->select()
                                                
->from($this->_tbl,array('croquis'))
                                                ->where('croquis_id = 
?',$this->_pt_num);                                       

                $stmt = $select->query();
                //$stmt->setFetchMode(Zend_Db::FETCH_LOB); ---
                $row = $stmt->fetchAll();
                $this->_croquis = $row->croquis;
        } catch (Zend_Db_Adapter_Exception $e) {
                                // perhaps a failed login credential, or 
perhaps the RDBMS is not running
                                echo "ZDBE somthing goes very wrong ".$e;
                } catch (Zend_Exception $e) {
                                // perhaps factory() failed to load the 
specified Adapter class
                                echo "ZE somthing goes very wrong ".$e;
                }

array(1) { [0]=>  object(stdClass)#37 (1) { ["croquis"]=>  resource(122) of 
type (stream) } }

How can I do this one ???

Thanks for the help


-- 

     Bruno Friedmann  [EMAIL PROTECTED]

Ioda-Net Sàrl   - www.ioda-net.ch
  2830 Vellerat - Switzerland

  Tél : ++41 32 435 7171
  Fax : ++41 32 435 7172
  gsm : ++41 78 802 6760

C'est Facile et Cool d'Évoluer en ligne : www.cfcel.com

Reply via email to