-
Notifications
You must be signed in to change notification settings - Fork 38
aql::select
stanistan edited this page Apr 18, 2011
·
2 revisions
$aql = "
artist {
name
where id = 10
}
";
$rs = aql::select($aql);
Prases to this SQL
SELECT artist.name as "name", artist.id as "artist_id" FROM artist as artist WHERE artist.active = 1 AND artist.id = 10
It will return a nested row record array.
Array
(
[0] => Array
(
[name] => Pink Floyd
[artist_id] => 10
[artist_ide] => BekjfoijeDZ
)
)
Table idenitifer and an encrypted table identifier (IDE) is returned automatically with the results.
AQL assumes that each table has the field active
. Instead of deleting records in a database, you can set active = 0
and it will return the same results.
artist_album {
name as album_name
}
artist {
name as artist_name
}
AQL will figure out joins automatically based on foreign keys in the table, but you can also write them explicitly.
artist_album {
name as album_name
}
artist on artist_album.artist_id = artist.id {
name as artist_name
}
For these types of queries, record identifiers will not be automatically added, so you may have to explicitly state them if you want them in the results.
distinct artist_album {
id as artist_album_id,
name as album_name
}
artist {
name as artist_name
}
For aggregate functions in queries, the appropriate fields are added to the group by
clause if they are not already there.