Here is what I currently have:
if ( !isset($_POST['action']) ) {
$data['projectList'] = $db->query( 'select' )
->distinct( true )
->table( 'projects' )
->get( 'userprojects.projectid as value' )
->get( 'projects.projectname as label' )
->join( 'userprojects', 'userprojects.projectid = projects.projectid' )
->join( 'clients', 'clients.clientid = projects.clientid' )
->where( 'userprojects.userid', $userid )
->exec()
->fetchAll();
This works fine. This is what I really want though:
if ( !isset($_POST['action']) ) {
$data['projectList'] = $db->query( 'select' )
->distinct( true )
->table( 'projects' )
->get( 'userprojects.projectid as value' )
->get( 'projects.projectname - clients.clientname as label' ) <<<<<<<<<<<<<<<<<<<<<<<<
->join( 'userprojects', 'userprojects.projectid = projects.projectid' )
->join( 'clients', 'clients.clientid = projects.clientid' )
->where( 'userprojects.userid', $userid )
->exec()
->fetchAll();
So basically two labels but only display them as one. I tried to do something like this:
$data['projectList'] = array();
while ( $row = $data->fetch() ) {
$data['projectList'][] = array(
"value" => $row['userprojects.projectid'],
"label" => $row['projects.projectname'].' '.$row['clients.clientname']
);
}
But I couldn't get it to work correctly. Any help would be greatly appreciated.