Sign In!
|
New User?Signup Now!
|
Forgot password?
Source Code 4 you
Home
Create Forum Topic
Check WebSite Rank
Publish Articles
UV Web Booster
Contact
Forum Type
Search Engine
.Net C# VB F# VC++
MonoPoject
Java J2EE
Zand Php Cake Php
Oracle Database Server
Mysql Database Server
DB2 Database Server
MSSql Databse Server
Javascript Ajax
Html Xml Xhtml
C Programming
C++ Programming
D Programming
CGI Programming
Perl Programming
Cobol Programming
Pascal Programming
Ruby Programming
Drupal Programming
Automobile
Software Testing
Linux Unix Mac Sun OS
Embedded Systems
Mainframe
IC Microcircuit Chip
Electronics Electrical
Hardware Netwarking
SAP ERP
Logical Reasoning
Human Resources
Science
Agriculture
Accounting
History
Pharmaceutical
Other Topic
Zand Php Cake Php
Posted by :
bberg
delete post AND unlink image
hi
i have a "posts" table with an image field.
it stores just the filename as a varchar of course.
how can i adapt the "delete" action so it also unlinks the image?
thanks
Posted by :
JamesF
Re : delete post AND unlink image
well you won't be adapting $this->Model->del() i hope but what you
could do is this:
..in your controller action:
//if record was deleted succesfully
if($this->Model->delete($this-
>Model->id))
{
//if image unlinks succesfully
if(unlink($image))
{
//success
}
else
{
//image failed to unlink
}
}
//else record did not delete
else
{
//record failed to delete
}
i personally would stuff this logic into my model and call it like
this:
$this->Model->
myDeleteFunction($data)
you would have to change every reference to $this->Model->function()
to $this->function()
when using the code in the model.
If you have the better reply, then send it to us. We will display your reply after the approval.
Name :
Email Id :
Reply :