chanh
(Chanh Ong)
March 16, 2009, 3:34am
1
I like what I see in Yii and I am thinking about replacing my core classes with Yii in my CMS however I have a couple questions:
. PDO substitute?
+ There are host that does not support PDO so how would I substitute PDO with some other form of database support?
+ If I want to use DBI4PHP or EZ_SQL or ADODB as the database layer, how hard would that be to add that into Yii?
. Can I use Yii framework as the framework classes as the foundation of my CMS?
. If I rewrite my CMS to fit into Yii which would be the least amount of work to approach this project?
Thanks
qiang
(Qiang Xue)
March 16, 2009, 11:08am
2
To substitute PDO, you need to write a new set of Yii PDO (CDbConnection etc.) based on DBI4PHP, EZ_SQL or ADODB. Once this is done, you can configure the 'db' app component to use your new CDbConnection class, and everything will work as if you have PDO.
Sure you can write a CMS using Yii, and that's one of the goals Yii is trying to achieve.
chanh
(Chanh Ong)
March 16, 2009, 12:43pm
3
Without PDO that mean I can't use AR or any of the yiic to generate code.
Is that code?
Thanks
qiang
(Qiang Xue)
March 16, 2009, 12:45pm
4
That's correct. But you can create a PDO substitution, everything will still work.
chanh
(Chanh Ong)
March 16, 2009, 12:50pm
5
So to do a PDO substitution so many files do I have to touch and how much work is involved.
Do I have to do the same each time you release a new version?
Is there a overload or something that I don't have to do a rewrite on each new release?
Thanks
chanh
(Chanh Ong)
March 20, 2009, 4:52am
6
If I want to substitute PDO with DBI4PHP will I only need to write substitue code for these method or are there more?
CDbCommand CDbCommand represents an SQL statement to execute against a database.
CDbConnection CDbConnection represents a connection to a database.
CDbDataReader CDbDataReader represents a forward-only stream of rows from a query result set.
CDbException CDbException represents an exception that is caused by some DB-related operations.
CDbTransaction CDbTransaction represents a DB transaction.
Thanks
qiang
(Qiang Xue)
March 20, 2009, 1:18pm
7
You will need to provide classes that are similar to CDbConnection, CDbCommand and CDbTransaction.
chanh
(Chanh Ong)
March 20, 2009, 2:28pm
8
Right but how would I do in such a way that when the yiic generate it will use the substitute class rather than the the original PDO class?
Thanks
qiang
(Qiang Xue)
March 20, 2009, 3:17pm
9
yiic doesn't generate code about DB connection. Once you have your own DB connection class, you can simply use it by configuring the 'db' component with:
'components'=>array(
'db'=>array(
'class'=>'path.to.MyDbConnection',
),
)
chanh
(Chanh Ong)
March 20, 2009, 7:13pm
10
That's nice but how about CDbCommand and CDbTransaction.
How is Yii know to use mine instead of build in classes?
Thanks
qiang
(Qiang Xue)
March 20, 2009, 7:22pm
11
The command and transaction instances are created by the connection instance. So you have full control.