http://developerspark.net/2012/09/select-insert-update-and-delete-query-in-zend-framework/
In Zend Framework It’s very easy to run select, insert, update and delete query,
Select Query in Zend Framework :
$sql = $this->select()
->from('tablename',array('*'))
->where('userID=?',1);
$data = $this->fetchAll($sql);
$data = $this->fetchRow($sql);
Insert query in Zend Framework :
Zend Framework provide the Insert function for insert the data :
You can use the Table object to insert rows into the database table on which the Table object is based. Use the insert() method of your Table object.
Create the Object :
<?php $userTable = new users(); ?>
<?php
$userProfileData = array(
'first_name'=>'David',
'add_line1'=>'UK',
'description'=>'something'
);
$userTable->insert($userProfileData);
?>
Update query in Zend Framework :
Zend Framework provide the Update function for update the data :
You can use the Table object to update the rows into the database table on which the Table object is based. Use the update() method of your Table object.
Create the Object :
<?php $userTable = new users(); ?>
<?php
$userProfileData = array(
'first_name'=>'David',
'add_line1'=>'UK',
'description'=>'something'
);
$userId =2;
$userTable->update($userProfileData,'userID='.$userId);
?>
Delete Query In zend Framework :
You can delete rows from a database table using the delete() method.
Create the Object :
<?php $userTable = new users(); ?>
<?php
$userId = 2 ;
$userTable->delete('user_id='.$userId); ?>