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.
It looks a lot like either CDbConnection or your MySQL server is misconfigured. In any way, it shouldn’t take that long to open a database connection. Are other applications that slow as well on your system? If so, the might be an error in your network stack.
Also: It looks like you just want to fetch the number of photos in a gallery. Your approach for that is a bit of an overkill: Use STAT-relations for that.
Care to c&p the relevant sections of your application’s config? Also: Is your CI app connecting through PDO? It is my understanding that this isn’t strictly necessary.
Heh, brilliant. You edited your post after I sent mine, haven’t you?
Well, there’s nothing striking me as particularly odd. Could be a deficiency of PDO, in which case I’d be unable to help you any further. You mgiht be well advised to open a ticket on the PHP bugtracker.
By any chance: Have you configure a cache component?
Ya this worked out actually this was not a yii problem it was due to pdo.
reasons:- on putting localhost it first tries to connect via ipv6 and then falls back to ipv4 while putting directly 127.0.0.1 it dosen’t do this refrence:- drupal blog.
Thanks for the solution. I think that’s a common problem. I’d like to see it mentioned on The Guide:DAO since that’s the first step for everyone who wants to connect to his database. I’d like to post a comment there, but I’m not allowed to do so.