开发者

Custom WHERE in storing JTable row in Joomla 1.5

I'm using JTable to store a record in a table. My table has 3 primary keys(pid,eid,sid). I want to store (Insert,update) a record my code:

$row =& JTable::getInstance('mytable', 'Table');
$row->load(
                array(
                    'pid'   =>$pid,
                    'eid'   =>$eid,
                    'sid' =>$sid
                    )
            );
$row->data = $data;
if (!$row->store()) {
                JError::raiseError(500, $row->getError() );
            }

The load function runs with warning: Warning: mysql_re开发者_如何学编程al_escape_string() expects parameter 1 to be string, object given in ...\joomla\database\database\mysql.php on line 193

and the store function raise an error:

, but the store raise an error with the SQL statement. The SQL statement contains the field names and new values and 'WHERE' keyword but without a condition.

any help?


The load function takes an integer as an input (see here http://docs.joomla.org/JTable/load) so you cannot pass it an array. The integer you pass it should be the primary key of your table. Here you can use any one of your 3 primary keys, because being primary it will be unique.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜