Zendcasts Forum

A community of developers who work with the Zend Framework and other enterprise PHP technologies

You are not logged in.

#1 2009-09-21 16:57:54

marche1990
New member
Registered: 2009-09-21
Posts: 1

ZC18: Zend_Db Update and Delete

I'm fairly new to the Zend Frame work and I love your casts :-D
I'm trying to understand some of the decisions you have made during them like:-

In this episode of ZendCasts you used a router to inform the framework that the final item in the URI was the id of the record to be edited or deleted.

Why did you not use a URI like

/index/update/id/7

surely this would lower the risk of failure in the future because you would not have to remember the change to the router.

Thanks in advance
Martin

Offline

#2 2009-09-21 19:07:32

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

Re: ZC18: Zend_Db Update and Delete

Hi martin,

this is the default functionality of the framework, and while its good as a starting point, such a route isn't search-engine optimized. Obviously, any conventions you choose to apply in you application will need to be documented and kept for your own sanity!

Offline

#3 2010-02-13 02:55:31

akongz
New member
Registered: 2010-02-13
Posts: 8

Re: ZC18: Zend_Db Update and Delete

Hi I want ask something about delete Action.

If we want to delete some row but I don;t know the id of PK but I have another 2 condition in where.

Like example I have name & email, in query sql must be :

DELETE FROM users
WHERE name = 'Eric' AND email = 'eric@email.com'

So how to do it in Zend?

Thanks.

Offline

#4 2010-02-14 21:26:31

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

Re: ZC18: Zend_Db Update and Delete

hi Akongz,

Example 18 on the documentation works in a similar way:

http://framework.zend.com/manual/en/zend.db.select.html

$minimumPrice = 100;
$maximumPrice = 500;

$select = $db->select()
             ->from('products',
                    array('product_id', 'product_name', 'price'))
             ->where('price > ?', $minimumPrice)
             ->where('price < ?', $maximumPrice);

I think you'll want to create a where clause and then pass it into the proper Zend_Db_* class instance.

Offline

#5 2010-02-15 09:09:15

akongz
New member
Registered: 2010-02-13
Posts: 8

Re: ZC18: Zend_Db Update and Delete

Hi jon,

I mean the code example delete is below :

$where = $table->getAdapter()->quoteInto('bug_id = ?', 1234);
$table->update($data, $where);

How to do same if I have 2 condition to delete something.
Are the parameter $where provide something array()?
like example below :

$where[] = $table->getAdapter()->quoteInto('name = ?', $name);
$where[] = $table->getAdapter()->quoteInto('description= ?', $description);
$table->update($data, $where);


And I already googling and I don't find any article about what different of methods quote(), quoteInto(), and quoteIdentifier(). Can u explain different the methods?

Thanks before

Offline

Board footer

Powered by FluxBB