Use getDataObjectSettings() more than 1 times

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Szdnez
Posts: 17
Joined: Tue Oct 20, 2009 12:48 pm

Use getDataObjectSettings() more than 1 times

Postby Szdnez » Sat Jan 16, 2010 7:07 am

Hello,

is it possible to use method getDataObjectSettings() more than 1 times for the same data object? For example

Code: Select all

$this->getDataObjectSettings( 'issue_settings', 'issue_id', $row['issue_id'], $myData );
$this->getDataObjectSettings( 'article_settings', 'article_id', $row['article_id'], $myData );

The problem is, that both use title in setting_name -> second call of getDataObjectSettings() overrides the data from the first call. Or must I do it by "hand"?

Thanks

Szdnez
Posts: 17
Joined: Tue Oct 20, 2009 12:48 pm

Re: Use getDataObjectSettings() more than 1 times

Postby Szdnez » Sat Jan 16, 2010 10:58 am

I wrote a method like this (nearly the same as original one, only one parameter more):

Code: Select all

function getDataObjectSettings( $pTableName, $pIdFieldName, $pIdFieldValue, &$pDataObject, $pSuffixFieldName )
{
   if ( $pIdFieldName !== null )
   {
      $sql = "SELECT * FROM $pTableName WHERE $pIdFieldName = ?";
      $params = array( $pIdFieldValue );
   }
   else
   {
      $sql = "SELECT * FROM $pTableName";
      $params = false;
   }
   $result =& $this->retrieve( $sql, $params );
   
   $suffix = '';
   if ( $pSuffixFieldName !== null )
   {
      $suffix = $pSuffixFieldName . '_';
   }

   while ( !$result->EOF )
   {
      $row = &$result->getRowAssoc( false );
      $pDataObject->setData( $suffix . $row['setting_name'], $this->convertFromDB( $row['setting_value'], $row['setting_type'] ), $row['locale'] );
      unset( $row );
      $result->MoveNext();
   }

   $result->Close();
   unset( $result );
}


Return to “OJS Development”

Who is online

Users browsing this forum: No registered users and 2 guests