Example #1
0
function createSelect($table, $columns, $conditions)
{
    $sql = "Select ";
    $control = 0;
    foreach ($columns as $index => $value) {
        $sql .= " {$index}";
        if ($control != count($columns) - 1) {
            $sql .= ",";
        }
        $control++;
    }
    $sql .= " from {$table} ";
    if ($conditions != null) {
        $sql .= createCondition($conditions);
    }
    return $sql;
}
Example #2
0
/**
 * 
 * @param string $table
 * @param array $columns
 * @param array $conditions
 * @return string
 */
function createSelect($table, $columns, $conditions)
{
    $sql = "Select";
    $control = 0;
    foreach ($columns as $value) {
        if ($control == count($columns) - 1) {
            $sql .= " {$value}";
        } else {
            $sql .= " {$value},";
        }
        $control++;
    }
    $sql .= " from {$table} " . createCondition($conditions);
    return $sql;
}