Module only returns strings, no integers

Author Message

Pål J Didriksen

Tuesday 28 June 2005 2:38:42 pm

I have a problem with the array returned from an extension module, and can't find out why.

I made a simple module, fetching content from an external table, called 'points'. Somehow, all values are returned as strings, even though most of them should be integers.

This is the code in 'points.php':

<?php

include_once( 'kernel/classes/ezpersistentobject.php' );

class Points extends eZPersistentObject
{

    function Points( $row )
    {
        $this->eZPersistentObject( $row );
    }

    function &definition()
    {
        $defArray= array( "fields" =>
               array(
                    'id' => array(
                    'datatype' => 'integer',
                    'default' => 0,
                    'name' => 'id',
                    'required' => true ),
              'contentobject_id' => array(
                    'name' => 'contentobject_id',
                    'datatype' => 'integer',
                    'default' => 0,
                    'required' => true ),
              'year' =>
              array('name' => 'year',
                    'datatype' => 'integer',
                    'default' => 0,
                    'required' => true ),
              'date' =>
              array('name' => 'date',
                    'datatype' => 'date',
                    'default' => 0,
                    'required' => false ),
              'category' =>
              array('name' => 'category',
                    'datatype' => 'integer',
                   'default' => 0,
                    'required' => false ),
              'title' =>
              array('name' => 'title',
                    'datatype' => 'string',
                    'default' => '',
                    'required' => false ),
              'points_int' =>
              array('name' => 'points_int',
                    'datatype' => 'integer',
                    'default' => 0,
                    'required' => false ) ),
           'keys' => array( 'id' ),
           'increment_key' => 'id',
           'class_name' => 'points',
           'sort'  => array( 'id' => 'asc'),
           'name' => 'points' );

        return $defArray;

    }

    function &fetchListFromDB( $parameters )
    {
        return Points::handleList( $parameters, false );
    }

    function &handleList( $parameters = array(), $asCount = false )
    {
        $parameters = array_merge( array( 'as_object' => true,
        'sort_by' => false,
        'offset' => false,
        'limit' => false,
        'contentobject_id' => true
         ),
        $parameters );

        $asObject = $parameters['as_object'];
        $offset = $parameters['offset'];
        $limit = $parameters['limit'];
        $sorts = $parameters['sort_by'];

        if (!$parameters['contentobject_id'] == "" )
            $conds = array('contentobject_id' => $parameters['contentobject_id']);
          $conds = "";

        $limitArray = null;
        if ( !$asCount and $offset !== false and $limit !== false )
        $limitArray = array( 'offset' => $offset,
                            'length' => $limit );

        $obj= eZPersistentObject::fetchObjectList( Points::definition(),
                                                    null, $conds, $sorts, $limitArray,
                                                    $asObject );

       return $obj;
    }

}

?>

Any tips, ideas or similar experiences?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.