473,493 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Add else Update if exist on table zend framework 1.

132 New Member
so i want update if exist this id on table else i want to insert add the data .
Expand|Select|Wrap|Line Numbers
  1. public function addUpdateCust(array $data)
  2. {
  3.  
  4.     if(!empty($data))
  5.     {
  6.         if($this->update($data, array('id = ?' => $data['id'])) > 0 )
  7.         {
  8.             return true;
  9.         }
  10.         $row = $this->createRow();
  11.         //$row->id           = $data['id'];
  12.         $row->code           = $data['code'];
  13.         $row->fabname        = $data['fabname'];
  14.         $row->namecustomer   = $data['namecustomer'];
  15.         $row->adresse        = $data['adresse'];           
  16.         $row->city           = $data['city'];           
  17.         $row->zipcode        = $data['zipcode'];           
  18.         $row->country        = $data['country'];           
  19.         $row->phone          = $data['phone'];       
  20.         $row->representative = $data['representative'];
  21.         $row->idUser         = NULL;
  22.  
  23.         //var_dump($row);
  24.         try {
  25.             return $row->save();           
  26.         } catch (Exception $e) {
  27.             return $e;
  28.         }
  29.     }
  30.     return false;
  31. }
Thanks in advance
Mar 31 '15 #1
3 1695
Dormilich
8,658 Recognized Expert Moderator Expert
you have to look up if and how ZF1 supports INSERT … ON DUPLICATE KEY UPDATE …
Apr 1 '15 #2
manjava
132 New Member
Thanks Dormilich ,so i have this method of update :
Expand|Select|Wrap|Line Numbers
  1. public function editCust(array $data)
  2.     {
  3.         if(!empty($data))
  4.         {
  5.             if($this->update($data, array('id = ?' => $data['id'])) > 0 )
  6.             {
  7.                 return true;
  8.             }
  9.             return false;
  10.         }
  11.         return false;
  12.     }
and i want to add to this function because i want do update if exist else add
Thanks in advance
Apr 1 '15 #3
Dormilich
8,658 Recognized Expert Moderator Expert
maybe this is of help.
Apr 1 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3219
by: R. Rajesh Jeba Anbiah | last post by:
The Zend framework preview release is out <http://framework.zend.com/> and I don't know why such PEAR like (yet another) framework is needed. At the same time, Rasmus' article...
1
1667
by: pjSoni | last post by:
Hi I would like to know from where to start learning zend frame work I need to develop project based on zend framework so what tools of zend framework I should use like db, template handling...
4
4443
by: chonny | last post by:
How to connect and query odbc database with zend framework db?
0
1594
by: hzqij1978 | last post by:
I am a newer of Zend Framework, i write a program to test the speed of Zend Framework, code like this: /var/www/htdocs/index.php <?php require_once 'Zend.php'; require_once...
1
1593
by: enkara | last post by:
Hi!! I'm trying to embebe an event calendar on my website but I'm usign Zend Framework and I don't know how to do it. It seems like Zend Framework doesn't accept third party tools. I don't know...
5
1488
by: Sanders Kaufman | last post by:
I've been programming a long time, but I'm not very bright these days. I've been using Zend Studio for a couple of years (LOVING IT!!) to build a web framework. I've been *hearing* about a...
3
3224
by: Peter Wang | last post by:
Hi, all. I recently encountered a very annoying problem while using Zend Framework(ZF). We use ZF in our web application, and it works fine at the beginning, but later when concurrent...
0
4937
by: Sean Quinn | last post by:
Hi All, First off let me say that from what I've seen of the XDebug debugger, I'm pretty impressed--it would just be nice if I could actually use it to its full potential in Eclipse. My...
0
1990
prabirchoudhury
by: prabirchoudhury | last post by:
Hi I am using Zend Framework and Ajax/JOSN. Ajax GET method return is working fine but for the PUT/POST update and Add method returning "403 Forbidden Error" and access permission. please...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.