Zend framework Zend-Join模型

Zend framework Zend-Join模型,zend-framework,join,models,Zend Framework,Join,Models,我有我的表的模型,并且希望使用模型而不是表进行连接。 例如,而不是: $select = $this->select() ->from(array('p' => 'products'), array('product_id', 'product_name')) ->join(array('l' => 'line_items'), 'p.product_id = l.product_id', ->limit(20, 10); 在指定要联接的表

我有我的表的模型,并且希望使用模型而不是表进行连接。 例如,而不是:

$select = $this->select()
 ->from(array('p' => 'products'),
   array('product_id', 'product_name'))
 ->join(array('l' => 'line_items'),
   'p.product_id = l.product_id',
 ->limit(20, 10);
在指定要联接的表名和列的地方,是否可以不使用模型

$select = $this->select()
 ->from(array('p' => 'products'),
   array('product_id', 'product_name'))
 ->join(array('l' => Model_Table1::tableName()),
   'p.product_id = l.product_id',
 ->limit(20, 10);

不。。。你不能加入两个模型。。。这些都是可以包含的类。。所以你们只能在控制器中使用这些类,或者也可以包含在另一个模型中。。。根据应用或要求

否。。。你不能加入两个模型。。。这些都是可以包含的类。。所以你们只能在控制器中使用这些类,或者也可以包含在另一个模型中。。。根据应用程序或要求

如果您的模型有一个名为的静态变量和一个返回变量的静态函数,我不明白为什么不这样做:

protected static $table = 'dbname';
public static function tableName() {
    return self::$table;
}

但是值得吗?表名是否会更改?

如果您的模型有一个名称为的静态变量和一个返回变量的静态函数,我不明白为什么不更改:

protected static $table = 'dbname';
public static function tableName() {
    return self::$table;
}

但是值得吗?表名是否会更改?

必须将完整性检查设置为false。像这样

$select = $this->select()
 ->setIntegrityCheck(false)
 ->from(array('p' => 'products'),
   array('product_id', 'product_name'))
 ->join(array('l' => 'line_items'),
   'p.product_id = l.product_id',
 ->limit(20, 10);

必须将完整性检查设置为false。像这样

$select = $this->select()
 ->setIntegrityCheck(false)
 ->from(array('p' => 'products'),
   array('product_id', 'product_name'))
 ->join(array('l' => 'line_items'),
   'p.product_id = l.product_id',
 ->limit(20, 10);

讨论中的模型控制着两个表(为了保持第六范式)。只包含一个表不是一个选项,并且所需的连接非常复杂。所讨论的模型控制两个表(为了保持正常形式)。仅包含一个表不是一个选项,并且所需的联接非常复杂。作为权宜之计,我创建其他模型的实例并根据需要获取行。作为权宜之计,我创建其他模型的实例并根据需要获取行。