mySQL throws error, but if copied from error message or die() into phpmyadmin it works
It looks like you are having trouble executing multiple lines of SQL inside the one string. You need to find out of PHP Class can handle running multiple lines.

Instead of getting the SQL to run dynamic SQL, just execute it yourself

$sql = 'SELECT IF(
    (SELECT COUNT(*)
            FROM INFORMATION_SCHEMA.COLUMNS
           WHERE table_name = "' . $this-&gt;t($table) . '"
             AND table_schema = DATABASE()
             AND column_name = "' . $column . '"
    ) &gt; 0,
    "SELECT 1;",
    "ALTER TABLE ' . $this-&gt;t($table) . ' ADD ' . $column . ' ' . $params . ';")';


Execute this one line, take that resulting string, and execute that.

Hey, it may means running two SQL commands, but it will work.

An alternative would be to write a stored procedure with that code and then call the stored procedure.

Please look at my answer to the post MySQL: Create index If not exists where I used dynamic SQL to create an index if an index does not exist. You could frame a stored procedure for yourself and call it from PHP.