armenio/zf3-cake-orm

Zend Framework 的 Cake ORM 模块

1.8.1 2021-07-22 21:39 UTC

This package is auto-updated.

Last update: 2024-09-23 05:09:56 UTC


README

Zend Framework 的 Cake ORM 模块

如何安装

  1. 通过 composer 安装。不知道如何操作?请查看这里 https://getcomposer.org.cn/doc/00-intro.md#introduction

  2. cd my/project/directory

  3. 编辑 composer.json

{
	"require": {
		"armenio/zf3-cake-orm": "1.*"
	}
}
  1. 编辑 config/application.config.php
'modules' => array(
	 'Application',
	 'Cake', // <==============================
)
  1. 在 cd my/project/directory/vendor/armenio/zf3-cake-orm/config/module.config.php 中更改您的模型命名空间
	'Cake' => array(
		'Configure' => array(
			'App' => array(
				'namespace' => 'Application' // <======= put your App/Module namespace HERE!
			),
		),
	),
  1. 创建您的模型

    6.1. 前往 my/project/directory/your/app/namespace

    6.2. 创建目录 Model/Table/

    6.3. 前往 my/project/directory/your/app/namespace/Model/Table/

    6.4. 创建文件 MyTable.php

<?php
namespace Application\Model\Table;

use Armenio\Cake\ORM\Table;

class MyTable extends Table
{
	// ...
}

更多信息请查看: https://book.cakephp.com.cn/3.0/en/orm.html

如何使用

<?php
use Armenio\Cake\ORM\TableManager;

$tableManager = new TableManager();

$table = $tableManager->get('MyTable');

$items = $table->find('all')->all();

foreach ($items as $row) {
	var_dump($row);
}