[TYPO3-mvc] Casting objects
Xavier Perseguers
typo3 at perseguers.ch
Thu Jul 9 12:11:58 CEST 2009
Hi Jochen,
>> Well, first of all I use Extbase naming conventions and partly base
>> classes but I cannot use it fully because when I last tried to use it
>> more than before (about 2 months ago) there was no support for my use
>> case, namely modeling a legacy MSSQL database where there is no "uid",
>> "pid", and the rest columns and I already had written my own
>> "DataMapper" specifically for this case. Note that for the time being, I
>> still don't persist anything, I just read data but I'll have too in a
>> near future and that the rest of TYPO3 runs on standard MySQL.
>
> You are right. Currently, the persistence layer expects an existing uid
> column.
OK.
> The new extbase persistence layer enables you to use joins as follows:
>
> $joinCondition = $this->QOMFactory->equiJoinCondition(
> $leftSelector,
> 'uid',
> $rightSelector,
> 'parent_uid'
> );
> $source = $this->QOMFactory->join(
> $leftSelector,
> $rightSelector,
> $joinType,
> $joinCondition
> );
> $query = $this->queryFactory->create($className());
> $query->setSource($source);
> $query->matching($query->equals('name', 'foo');
> $objects = $query->execute();
Great!
> I am going to implement another feature (one of the last ones before
> feature freeze) which enables you to say
>
> $query = $this->queryFactory->create($className());
> $query->setStatement('SELECT ... FROM (SELECT ... FROM ... WHERE ...)');
> $objects = $query->execute();
Great! But did you rewrite the SQL parser from TYPO3? I guess no, this
means that such statements won't be able to be passed to DBAL.
This is actually the main problem from DBAL from my point of view. It
relies on TYPO3's SQL parser which is quite poor and only works for very
simple queries. If we could somehow outsource this parser (I don't know
if the query aka CRUD part still should be kept into Core) - as said I
only speak about CRUD part, not table structure part - and make it part
of DBAL, then a better SQL parser could be used and DBAL would finally
be really usable for real world applications.
> Lazy Loading works now (as a Proxy implementation). You have to specify
> the loading strategy in the $TCA like for the Posts in a Blog:
>
> 'posts' => array(
> [...]
> 'config' => array(
> 'type' => 'inline',
> 'loadingStrategy' => 'proxy', // Here
> 'foreign_class' => 'Tx_BlogExample_Domain_Model_Post',
> 'foreign_table' => 'tx_blogexample_domain_model_post',
> 'foreign_field' => 'blog_uid',
> 'foreign_table_field' => 'blog_table',
> [...]
> )
> ),
Good to know!
Regards
Xavier
--
Xavier Perseguers
DBAL-Member
http://xavier.perseguers.ch/en/tutorials/typo3.html
More information about the TYPO3-project-typo3v4mvc
mailing list