1

I am a new to yii although i have worked a lot with codeigniter and was just trying to convert my code from codeigniter to yii But the CDbconnection is taking more than 1 second to execute i have attached a screenshot. also the sql code i am using.

$criteria = new CDbCriteria();
$criteria->select = "total_photos";

$data = array( 'Gallerys' => Gallerynames::model()->findAll($criteria));

Please look into itScreen shot of the log

Edit:

Here is my db config

'db'=>array(
        'class' => 'system.db.CDbConnection',
        'connectionString' => 'mysql:host=localhost;dbname=yiiwiki',
        'emulatePrepare' => true,
        'username' => 'root',
        'password' => '',
        'charset' => 'utf8',
        'enableProfiling' => true,
        'schemaCachingDuration' => 3600,
    ),
bool.dev
  • 17,508
  • 5
  • 69
  • 93
Anand mohan sinha
  • 588
  • 2
  • 5
  • 11

1 Answers1

2

From yii guide

Because ActiveRecord relies on the metadata about tables to determine the column information, it takes time to read the metadata and analyze it. This may not be a problem during development stage, but for an application running in production mode, it is a total waste of time if the database schema does not change.

so set the schemaCachingDuration of the db application component a value greater than zero. 'db'=>array( 'class'=>'system.db.CDbConnection', 'connectionString'=>'sqlite:/wwwroot/blog/protected/data/blog.db', 'schemaCachingDuration'=>3600, ),

Keep in mind that you should specify a valid cache in the application config

EDIT It seems your problem is not due to the schema. Refering to this changing localhost to 127.0.0.1 will fix it

Community
  • 1
  • 1
dInGd0nG
  • 4,162
  • 1
  • 24
  • 37