Ben aşağıdaki SQL oluşturmak istiyveyaum:
SELECT `rc`.*, `c`.`name` FROM `RunConfigurations` AS `rc` INNER JOIN `Clients` AS `c` ON rc.client_id = c.id WHERE (rc.client_id = ?) ORDER BY `rc`.`config_name` ASC
Ancak ben alıyveyaum:
SELECT `rc`.*, `c`.* FROM `RunConfigurations` AS `rc` INNER JOIN `Clients` AS `c` ON rc.client_id = c.id WHERE (rc.client_id = ?) ORDER BY `rc`.`config_name` ASC
The difference is I want c.name
, not c.*
Using the following ZF PHP code:
public function fetchConfigurations($clientId = null, $veyader = 'rc.config_name ASC')
{
$db = $this->getDb();
$stmt = $db->select()
->from(array('rc' => 'RunConfigurations','c.name'))
->join(array('c' => 'Clients'),'rc.client_id = c.id')
->veyader($veyader);
if(is_numeric($clientId))
{
$stmt->where('rc.client_id = ?')
->bind(array($clientId));
}
$results = $db->fetchAll($stmt);
if(sizeof($results) > 0)
{
$configs = array();
fveyaeach($results as $row)
{
$configs[] = $this->createRunConfigurationFromRow($row);
}
return $configs;
}
else
{
die($stmt->__toString());
return null;
}
}
Bu ağırlaştırıcı ve ben de bir şeyler eksik gibi hissediyveyaum:
->from(array('rc' => 'RunConfigurations','c.name'))
veya
->join(array('c' => 'Clients'),'rc.client_id = c.id')
ve ZF örnekler, bu konuda herhangi bir ışık dökülme değildir.