php support?

joep

New Member
I've searched here and the web trying to see if there's any native support for php access to the Progress database, but in vain. Does anyone know if it exists or if there are any plans to ever have a php native api?
 

Casper

ProgressTalk.com Moderator
Staff member
Well depends on what you call native support:
I'd say:
  • sql access
  • webservices
Casper.
 

joep

New Member
Well depends on what you call native support:
I'd say:
  • sql access
  • webservices
Casper.

I call native support a php driver written for progress, akin to the mysql, postgresql and Oracle drivers that php has already. I have SQL access through ODBC, but it's quite weird and non-standard. ("standard" being mySQL!)

In the time since I made the OP, I've decided to go it alone. There's a framework called Cakephp that handles ODBC but it doesn't subscribe to the Progress way of doing things, so I'm re-writing the ODBC portion of the framework to support Progress (as well as possible). From what I understand, Sybase and a few other DBMS are similar to Progress. If anybody is interested in this little project of mine, feel free to ask questions or provide suggestions. I'm writing this against a 9.1E database, if that makes a difference.

Here's a sample of what I've done so far. This is the original &describe function in cake/libs/models/datasources/dbo/dbo_odbc.php:
Code:
/**
 * Returns an array of the fields in given table name.
 *
 * @param Model $model Model object to describe
 * @return array Fields in table. Keys are name and type
 */
    function &describe(&$model) {
        $cache=parent::describe($model);

        if ($cache != null) {
                return $cache;
        }

        $fields = array();
        $sql = 'SELECT * FROM ' . $this->fullTableName($model);
        $result = odbc_exec($this->connection, $sql);

        $count = odbc_num_fields($result);

        for ($i = 1; $i <= $count; $i++) {
                $cols[$i - 1] = odbc_field_name($result, $i);
        }

        foreach ($cols as $column) {
            $type = odbc_field_type(odbc_exec($this->connection, 'SELECT ' . $column . ' FROM ' . $this->fullTableName($model)), 1);
            $fields[$column] = array('type' => $type);
        }

        $this->__cacheDescription($model->tablePrefix . $model->table, $fields);
        return $fields;
    }
And this is my reworking of it to get Progress to give up the information required...
Code:
/**
 * Returns an array of the fields in given table name.
 *
 * @param Model $model Model object to describe
 * @return array Fields in table. Keys are name and type
 */
    function &describe(&$model) {

        $cache=parent::describe($model);

        if ($cache != null) {
                return $cache;
        }

        $fields = array();
    // modifying this area to be incompliance with Progress DB's quirks
    // Can't have those backtics on the table name...
        $myTableName = $this->stripTics($this->fullTableName($model));

    // Use Progress's SYSPROGRESS table to get the column attributes of the table
        $sql = ' SELECT "SYSCOLUMNS"."COL",
                        "SYSCOLUMNS"."WIDTH",
                        "SYSCOLUMNS"."COLTYPE"
                        FROM   "SYSPROGRESS"."SYSCOLUMNS" "SYSCOLUMNS"
                WHERE  "SYSCOLUMNS"."TBL"=\''.$myTableName.'\'';

        $result = odbc_exec($this->connection, $sql);
                
        while (odbc_fetch_row($result)) {
            $column = odbc_result($result, 1);
            $type     = odbc_result($result, 3);
            $fields[$column] = array('type' => $type);
        }
        
        $this->__cacheDescription($model->tablePrefix . $model->table, $fields);
        return $fields;
    }
/**
 * Returns the table name stripped of the tic marks. 
 *
 * @param string $tableName String to be stripped of tics for Progress DB use
 * @return string "naked" table name, just the characters, ma'am 
 * @todo Clean up this whole thing for production
 */    
    function stripTics($tableName) {
        $myTableNameLength = strlen($tableName);
        $myTableName = substr($tableName, 1, $myTableNameLength - 2);
        return $myTableName;
    }
Suggestions are welcome.
 

tjessy

New Member
In the time since I made the OP, I've decided to go it alone. There's a framework called Cakephp that handles ODBC but it doesn't subscribe to the Progress way of doing things, so I'm re-writing the ODBC portion of the framework to support Progress (as well as possible). From what I understand, Sybase and a few other DBMS are similar to Progress. If anybody is interested in this little project of mine, feel free to ask questions or provide suggestions. I'm writing this against a 9.1E database, if that makes a difference.
Suggestions are welcome.

Hello Joep,

we are dealing with the same problem as you. The only way we found is a JDBC connection which can query a progress database and send back the information. Unfortunately this "solution" is very slow (a simple select query takes around 30 secs to compete in a nearly 2M rows database with a few hundred results) so I'm very much interested about your project! :) Did you have a chance to test it? Maybe we can help you with this... ;)

Cheers,
John
 
Top