It is stated here that, in the example above, the LASTUPD field in the database table was incorrectly punched into a lastudp, and this case is corrected.
In addition to the Appeal field database is consistent with the previous example.
The project still follows the example, such as:
The code is in turn:
Database.php: Consistent with the previous example.
companies_controller.php:
-
- class Companiescontroller extends AppController
- {
- var $name = ' Companies ';
-
- function index ()
- {
- $this->set (' companies ', $this->company-> FindAll ());
- }
-
- function view ($id = null)
- {
- $this->company->id = $id;
- $this->set (' Company ', $this Company->read ());
- }
-
- function Add ()
- {
- if (! Empty Empty ($this->data))
- {
- if ($this->company->save ($this- >data))
- {
- $this->flash (' Your post has been saved. ' , '/companies ' );
- }
- }
- }
-
- function edit ($id = null)
- {
- if (emptyempty($this->data ))
- {
- $this->company->id = $id;
- $this->data = $this->company->read ();
- }
- else
- {
- if ($this->company->save ($this->data[ ' company ' ))
- {
- $this->flash (' Your post has been updated. ' , '/companies ' );
- }
- }
- }
-
- function delete($id)
- {
- $this->company->del ($id);
- $this->flash (' The post with ID: '. $id . ' has been deleted. ' , '/companies ' );
- }
- }
- ?>
company.php:
-
- class Company extends Appmodel
- {
- var $name = ' company ';
-
- var $validate = array(
- ' company ' = Valid_not_empty,
- ' price ' = Valid_not_empty,
- ' change ' = Valid_not_empty,
- ' lastupd ' = Valid_not_empty
- );
- }
- ?>
Index.thtml:
Test Companies
- foreach ( $companies as $company):?>
- Endforeach ;?>
Id |
| Company
| Price
| Change Last
update |
!--? PHP echo $company [ ' company ' ] ' ID ' ];. |
- !--? php echo $html ->link ( $company [ ' company ' [ ' company ' ], . $company [ ' company ' [ ' ID ' ]);?
-
- !--? php echo $html ->link ( , "/companies/delete/{$company [' Company '] [' ID ']} ' , NULL, is you sure? ' )?
-
|
Echo $company[' Company '] [' price '];?> |
Echo $company[' Company '] [' Change '];?> |
Echo $company[' Company '] [' lastupd '];?> |
- Echo $html->link (' Add ', ' /companies/add');?>
View.thtml:
Company: echo $company[' company '][' Company ']?>
ID: echo $company[' company '][' id ' ]?>
Price: echo $company["Company"] [' price '] ?>
Change: echo $company[' company '][' Change ']?>
Lastupdate: echo $company[' company '] [ ' lastupd ' ]?>
- Echo $html->link (' edit ', ' /companies/edit/'). $company [' Company '] [' id ']);?>
Add.thtml:
ADD Company
Edit.thtml:
Edit Company
You can test your code with this access to http://localhost/cakephp/companies.
http://www.bkjia.com/PHPjc/319619.html www.bkjia.com true http://www.bkjia.com/PHPjc/319619.html techarticle It is stated here that, in the example above, the LASTUPD field in the database table was incorrectly punched into a lastudp, and this case is corrected. In addition to the Appeal field database is consistent with the previous example. The project still follows the example of ...