Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

第49回Php勉強会@関東 Datasource

0 views

Published on

Published in: Technology
  • Be the first to comment

第49回Php勉強会@関東 Datasource

  1. 1. Datasource id:kaz_29(kaz29) 2010/1/30 49 PHP @
  2. 2. • •( ) (E2) • • • CMS • id:kaz_29(kaz29) • PHP 4 • baker
  3. 3. CakePHP
  4. 4. Datasource
  5. 5. Datasource
  6. 6. Datasource
  7. 7. Datasouce
  8. 8. Datasource • • MySQL, PostgresSQL http://book.cakephp.org/ja/view/87/DataSources
  9. 9. Datasource • app/config/database.php Database Datasource http://book.cakephp.org/ja/view/87/DataSources
  10. 10. dbo_source • RDB Datasourse • mysql,pgsql,sqlite,ms sql,oracle etc... ~/cake/libs/models/datasources
  11. 11. Datasource • CSV Datasource http://bakery.cakephp.org/articles/view/csv-datasource-for- reading-your-csv-files • Twitter Datasource http://bakery.cakephp.org/articles/view/twitter-datasource • CouchDB datasource for CakePHP http://github.com/jperras/divan/blob/master • mongoDB datasource for cakephp http://github.com/ichikaway/mongoDB-Datasource ...
  12. 12. Datasource <?php class DATABASE_CONFIG { datasource var $csv = array( 'datasource' => 'csv', 'path' => '.csv', 'extension' => 'csv', 'readonly' => true, 'recursive' => false, ); } APP/config/database.php database
  13. 13. Datasource // database <?php class User extends Model { var $useDbConfig = 'csv' ; } database
  14. 14. Datasource class FooController extends AppController { var $uses = array('User'); function index() { $users = $this->User->find('all') ; ..... } }
  15. 15. atomfeed Datasouce
  16. 16. • app/models/datasources • hoge_source.php • HogeSource • DataSource
  17. 17. Method
  18. 18. Method • listSources - • describe - • calculate - COUNT(*)
  19. 19. listSource function listSources() { return array('bookmarks') ; }
  20. 20. describe function describe(&$model) { return array( 'tag' => array( 'type' => 'string', 'null' => true, 'default' => null, 'length' => 512, ), ); }
  21. 21. caluculate function calculate( &$model, $func, $params = array()) { return array('count' => true); }
  22. 22. method • create - • update - • read - • delete -
  23. 23. • create(&$model, $fields = array(), $values = array()) • update(&$model, $fields = array(), $values = array()) $model->id $model->alias
  24. 24. • delete($model, $id = null)
  25. 25. • read(&$model, $queryData = array()) $queryData Array ( [conditions] => Array ( [feed] => http://b.hatena.ne.jp/hoge/atomfeed ) [fields] => Array([count] => 1) [joins] => Array() [limit] => [offset] => [order] => Array([0] => ) [page] => 1 [group] => [callbacks] => 1 )
  26. 26. read function read(&$model, $query) { if ($model->findQueryType === 'count') { // .... $result = array(array(array(‘count’=>$count))); } else { // .... $result = array(array($model->alias =>[ ]))); } return $result ; }
  27. 27. • 1.2 Datasource Plugin • 1.3 beta Plugin
  28. 28. Datasouce Datasouce (^^
  29. 29. >< question?

×