What steps will reproduce the problem?
$db=Yii::app()->db;
$id = Yii::app()->user->id;
$page = Yii::app()->getRequest()->getUrl();
$sql="UPDATE table SET page=:page, time=:time WHERE id=:id";
$cmd = $db->createCommand($sql);
$cmd->bindParam(":page", $page, PDO::PARAM_STR);
$cmd->bindParam(":time",time(),PDO::PARAM_INT);
$cmd->bindParam(":id", $id, PDO::PARAM_INT);
$cmd->execute();
What is the expected output? What do you see instead?
It should write the values in the database. The time value was updated all
the time, but the page value should be e.g.
"/project/index.php?r=module/user/show&user=kenci", but it has been saved
as "/project/". On Firefox 3.5 all works fine, but this issue happens only
on Internet Explorer 8!?
What version of the product are you using? On what operating system?
Yii-1.1rc, PHP 5.2.9, Windows Xp Pro, XAMPP 1.7.1
Migrated from http://code.google.com/p/yii/issues/detail?id=761
earlier comments
qiang.xue said, at 2009-12-25T17:09:46.000Z:
Are you saying that Yii::app()->getRequest()->getUrl() returns different values for
different browsers? I couldn't reproduce this issue.
coxxirani said, at 2009-12-25T22:47:45.000Z:
No, Yii::app()->getRequest()->getUrl() returns allways the same value
"/project/index.php?r=module/user/show&user=kenci".
If i save this into the mySQL database, on IE8(IE7) it allways writes "/project/" in
the page column. On Firefox, Safari, it writes
"/project/index.php?r=module/user/show&user=kenci" as it should be.
I really dont know why.
coxxirani said, at 2009-12-25T23:39:29.000Z:
Now i have done this:
$sql="INSERT INTO table (id, time, page) VALUES (:id, :time, :page)";
$cmd = $db->createCommand($sql);
$cmd->bindParam(":time",time(),PDO::PARAM_INT);
$cmd->bindParam(":page", $page, PDO::PARAM_STR);
$cmd->bindParam(":id", rand(0, 200), PDO::PARAM_INT);
$cmd->execute();
So it creates me an random "id" value. If i execute this code in IE it writes two
rows, one with '/project/', one with 'project/index.php?r=module/user/show&user=kenci'.
On Firefox it writes one column with
'project/index.php?r=module/user/show&user=kenci'. Really strange.
qiang.xue said, at 2009-12-26T02:36:10.000Z:
It seems in IE, the same action is executed twice. Try to enable file-based logging
and verify this.
Anyway, this should not be a problem of SQL query.
coxxirani said, at 2009-12-26T10:20:20.000Z:
##On Internet Explorer##
2009/12/26 11:16:01 [trace] [system.db.CDbConnection] Opening DB connection
2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Executing SQL: UPDATE table SET
time=:time, page=:page WHERE id=:id. Bind with parameter :time=[integer],
:page=[string], :id=[string]
2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM
`users`
2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE
`users`
2009/12/26 11:16:01 [trace] [system.db.ar.CActiveRecord] Users.find()
2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM
`users` WHERE username=:username LIMIT 1. Bind with parameter :username='kenci'
2009/12/26 11:16:01 [trace] [system.db.CDbConnection] Opening DB connection
2009/12/26 11:16:01 [trace] [system.db.CDbCommand] Executing SQL: UPDATE table SET
time=:time, page=:page WHERE id=:id. Bind with parameter :time=[integer],
:page=[string], :id=[string]
On Firefox
2009/12/26 11:16:40 [trace] [system.db.CDbConnection] Opening DB connection
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Executing SQL: UPDATE table SET
time=:time, page=:page WHERE id=:id. Bind with parameter :time=[integer],
:page=[string], :id=[string]
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Querying SQL: SHOW COLUMNS FROM
users
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Querying SQL: SHOW CREATE TABLE
users
2009/12/26 11:16:40 [trace] [system.db.ar.CActiveRecord] Users.find()
2009/12/26 11:16:40 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM
users
WHERE username=:username LIMIT 1. Bind with parameter :username='kenci'
coxxirani said, at 2009-12-26T10:41:49.000Z:
I have found out that this has to do something with the html code.
http://bugs.php.net/bug.php?id=19326
I used the Yii 'classic' theme, and now it updates the row only one time.