Location: PHPKode > projects > Php simple acces data mysql > phpsimpledb_v2/manage/projets/generation/templates-files/object.class.php
<?php
//recherche la clee primaire
$sPrimaryKey = '';
foreach( $oObject->oFields as $oField )
	if( $oField->sKey == 'PRI' ){
		$sPrimaryKey = $oField->sName;
	}

//recherche des collections
$sCollection = '';
foreach( $oObjects as $oItemObject ){
	if( $oItemObject->sName != $oObject->sName ){
		foreach( $oItemObject->oFields as $oField ){
			if( $oField->sTypeField == 'object' && $oField->sLinkObject == $oObject->sName ){
				$sCollection .= '\''.$oItemObject->sName.'\', ';
			}
		}
	}
}
$sCollection = rtrim( $sCollection, ', ' );
if( $sCollection != '' )
	$sCollection = ' '.$sCollection.' ';

$sData = '<?php
	class PHPSIMPLEDB_object_'.$oObject->sName.' extends PHPSIMPLEDB_extends_object{
		
		var $_oPHPSIMPLEDB = NULL;
		var $_oInfos = array( \'table\' => \''.$oObject->sTable.'\', \'primarykey\' => \''.$sPrimaryKey.'\', \'name\' => \''.$oObject->sName.'\', \'tagname\' => \''.$oObject->sTagname.'\', \'desc\' => \''.$oObject->sDesc.'\' );
		var $_oFields = array('."\n";

foreach( $oObject->oFields as $oField ){
	$sType = $oField->sType;
	$sSize = 'NULL';
	$iPos_start = stripos( $sType, '(' );
	if( $iPos_start !== false ){
		$iPos_stop = stripos( $sType, ')' );
		$sSize = substr( $sType, $iPos_start + 1, $iPos_stop - ( $iPos_start + 1 ) );
		$sType = substr( $sType, 0, $iPos_start );
	}
	$sData .= '			\''.$oField->sName.'\'=>array( \'typefield\' => \''.$oField->sTypeField.'\', \'linkobject\' => \''.$oField->sLinkObject.'\', \'name\' => \''.$oField->sName.'\', \'type\' => \''.$sType.'\',\'size\' => '.$sSize.', \'key\' => \''.$oField->sKey.'\', \'interclassement\' => \''.$oField->sInterclassement.'\', \'attributs\' => \''.$oField->sAttributs.'\', \'null\' => \''.$oField->sNull.'\', \'defaut\' => \''.$oField->sDefaut.'\', \'extra\' => \''.$oField->sExtra.'\', \'value\' => NULL ),'."\n";
}
$sData = rtrim( $sData, ','."\n" );
$sData .= ' );
		var $_oCollections = array('.$sCollection.');

		/** Constructeur de '.$oObject->sName.' */
		public function __construct( $oPHPSIMPLEDB ){
			$this->_oPHPSIMPLEDB = $oPHPSIMPLEDB;
		}
	}
?>';
?>
Return current item: Php simple acces data mysql