|
|||
|
Hello all,
I've been using the Zend framework for a while now, but I've run into a problem with the Zend_Db class: When trying to use the code in the documentation here Zend Framework: Documentation (Example 10.105. Example of changing a column in a row) I'm finding that PHP throws an exception saying, "Notice: Trying to get property of non-object" - this refers to this line in the example, "$row->bug_status = 'FIXED';". So it seems that either I've missed something simple, or the Zend framework has changed and the documentation hasn't been updated. Any help would be muchly appreciated! Regards, Socceroos. Last edited by socceroos : 11-22-2007 at 08:49 PM. |
|
|||
|
Here is the code that I use:
Code:
$where = "SELECT * FROM table WHERE ".$this->DB->quoteInto('user = ? ', $this->user['id']);
$where .= " AND ".$this->DB->quoteInto('blocks LIKE ? ', $block);
$row = $this->DB->fetchRow($where);
// Change the value of the blocks columns
$rowBlocks = split(',', $row->blocks);
foreach ($rowBlocks as $value)
{
if($block != $value)
{
$blockArray = $value;
}
}
$row->blocks = $blockArray;
// UPDATE the row in the database with new values
$row->save();
|
|
|||
|
I do it this way:
Code:
$data = array(
"field1" => "value1",
"field2" => "value2"
);
$where = "id = " . $id;
$table = new Table();
$table->update($data, $where);
|
|
|||
|
Thanks for the reply nomark.
The only thing is that I can't seem to access the row retrieved from the database using the object method. The documentation makes it clear that you should be able to access your row's column data using the object method...... Why this doesn't work for me, I don't know. If you look at the link to the documentation I gave in my first post, you can see how they access the row data using object enumeration. Does anyone know if this still exists in the Zend Framework? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|