As I known Yii use PDO extension for Mysql. But I do not like it. I have own written class to work with the mysql database. How to use own mysql provider in my project whith Yii corectly?
As I known Yii use PDO extension for Mysql. But I do not like it. I have own written class to work with the mysql database. How to use own mysql provider in my project whith Yii corectly?
you wrote extension in C ?
pdo is not raw php
I believe not …
you can add it as component!
No, I write php class.
Now I have
class db {
}
And if I want use as component, I think it will be like
class db extends CComponent {
}
But this class use other scripts - not Yii.
all the idea behind framework is stop reinventing the wheel as most of as did, so you better stop using your own when it exists tested and ready to use
And yet, how I can use my class in Yii app?
You cannot unless you do not want to use any database functionality that yii provides to you (ActiveRecord pattern, findAll… Methods, CActiveRecord Models etc…) OR you are ready to override every single class that uses PDO (quite a lot classes. Thats all packages under system.db., system.db.ar., system.db.schema., system.db.schema.mssql., system.db.schema.mysql., system.db.schema.oci., system.db.schema.pgsql., system.db.schema.sqlite.)
Moreover, choosing the last method you will need to maintain your code after every yii version update which is likley to change some releated code.
Why would anyone want to do that?!
At first: Not everyone have PDO_mysql extention on hosting. If you not believe, just believe.
Second: I dont need 402kb of all database connection eg. oracle, mssql, sqlite and pgsql
Third: I have own PHPClass which can do all CRUD operation and they have 10kb( 2 script to work whith mysql and mysqli, thats mean that use only 5kb). U can View in attachment mysqli.class
So, what a problem to receive data with another class?
ok maybe anybody help me whith next.
I have object - instance of some class.
$obj = new SomeClass();
How I can use this object in all extended class in Yii?
You may want to have a closer look at the PHPPDO extension.
For questions unrelated to this topic, please open a new thread.
/Tommy