CakePHP Cookbook 3.x
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 12 Database Access & ORM 463 Quick Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . “Comment”, or “Photo”. If we wanted to load some data from our users table we could do: use Cake\ORM\TableRegistry; (continues on next page) 1 CakePHP Cookbook Documentation, Release 3.10 (continued If we wanted to make a new user and save it (with validation) we would do something like: use Cake\ORM\TableRegistry; // Prior to 3.6 use TableRegistry::get('Users') $users = TableRegistry::getTableLo0 码力 | 967 页 | 2.80 MB | 1 年前3CakePHP Cookbook Documentation 5.x
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 12 Database Access & ORM 321 Quick Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . “Comment”, or “Photo”. If we wanted to load some data from our users table we could do: use Cake\ORM\Locator\LocatorAwareTrait; (continues on next page) 1 CakePHP Cookbook Documentation, Release 5 If we wanted to make a new user and save it (with validation) we would do something like: use Cake\ORM\Locator\LocatorAwareTrait; $users = $this->getTableLocator()->get('Users'); $user = $users->newEntity(['email'0 码力 | 848 页 | 2.53 MB | 1 年前3CakePHP Cookbook 4.x
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 12 Database Access & ORM 419 Quick Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . “Comment”, or “Photo”. If we wanted to load some data from our users table we could do: use Cake\ORM\Locator\LocatorAwareTrait; (continues on next page) 1 CakePHP Cookbook Documentation, Release 4 If we wanted to make a new user and save it (with validation) we would do something like: use Cake\ORM\Locator\LocatorAwareTrait; $users = $this->getTableLocator()->get('Users'); $user = $users->newEntity(['email'0 码力 | 967 页 | 2.88 MB | 1 年前3CakePHP Cookbook 3.x
Migration Guide 3.1 Migration Guide 3.1 Migration Guide 3.0 Migration Guide 3.0 Migration Guide New ORM Upgrade Guide Tutorials & Examples Content Management Tutorial Getting CakePHP Checking our Installation Own View Classes More About Views View Cells Themes JSON and XML views Helpers Database Access & ORM Quick Example More Information Database Basics Query Builder Table Objects Entities Retrieving Data “Comment”, or “Photo”. If we wanted to load some data from our users table we could do: use Cake\ORM\TableRegistry; // Prior to 3.6 use TableRegistry::get('Users') $users = TableRegistry::getTableLo0 码力 | 1244 页 | 1.05 MB | 1 年前3CakePHP Cookbook 4.x
Own View Classes More About Views View Cells Themes JSON and XML views Helpers Database Access & ORM Quick Example More Information Database Basics Query Builder Table Objects Entities Retrieving Data “Comment”, or “Photo”. If we wanted to load some data from our users table we could do: use Cake\ORM\Locator\LocatorAwareTrait; $users = $this->getTableLocator()->get('Users'); $resultset = $users->find()->all(); If we wanted to make a new user and save it (with validation) we would do something like: use Cake\ORM\Locator\LocatorAwareTrait; $users = $this->getTableLocator()->get('Users'); $user = $users->newEntity(['email'0 码力 | 1249 页 | 1.04 MB | 1 年前3CakePHP Cookbook Documentation 5.x
Own View Classes More About Views View Cells Themes JSON and XML views Helpers Database Access & ORM Quick Example More Information Database Basics Query Builder Table Objects Entities Retrieving Data “Comment”, or “Photo”. If we wanted to load some data from our users table we could do: use Cake\ORM\Locator\LocatorAwareTrait; $users = $this->getTableLocator()->get('Users'); $resultset = $users->find()->all(); If we wanted to make a new user and save it (with validation) we would do something like: use Cake\ORM\Locator\LocatorAwareTrait; $users = $this->getTableLocator()->get('Users'); $user = $users->newEntity(['email'0 码力 | 1080 页 | 939.39 KB | 1 年前3CakePHP Cookbook 2.x
modified field exists for the model being updated, it is not going to be updated automatically by the ORM. Just add it manually to the array if you need it to be updated. For example, to close all tickets $this->Products->ProductsItems->virtualFields['Total'] = 'count(ProductsItems.products_id)'; // Where ORM $where = array( 'fields' => array( 'Products.*', 'count(ProductsItems.products_id) fields arrays. Doing so will generally result in an SQL error as the fields are not replaced by the ORM. This is because it difficult to estimate the depth at which an associated model might be found. A0 码力 | 1096 页 | 958.62 KB | 1 年前3CakePHP Cookbook 2.x
modified field exists for the model being updated, it is not going to be updated automatically by the ORM. Just add it manually to the array if you need it to be updated. For example, to close all tickets $this->Products->ProductsItems->virtualFields['Total'] = 'count(ProductsItems.products_ ˓→id)'; // Where ORM $where = array( 'fields' => array( 'Products.*', 'count(ProductsItems.products_id) AS ProductsItems__Total' fields arrays. Doing so will generally result in an SQL error as the fields are not replaced by the ORM. This is because it difficult to estimate the depth at which an associated model might be found. A0 码力 | 820 页 | 2.52 MB | 1 年前3
共 8 条
- 1