I have a model helper called ValuesHelper in common/models with the following code snippet:
<?php
namespace common\models;
class ValueHelpers
{
/**
* return the value of status by the its name string
* example: 'Active'
* @param string $status_name
*/
public static function getStatusValue($sta8tus_name)
{
$connection = \Yii::$app->db;
$sql = "SELECT id FROM status WHERE status_name=:status_name";
$command = $connection->createCommand($sql);
$command->bindValue(':status_name', $status_name);
// the issue in the next line
$result = $command->queryOne() or die($connection->getFirstError()."error");
return $result['id'];
}
}
I don't know how to implement like mysql_error() in or die() clause. I tried or die ($command->getFirstError()) but it failed too. By the way, on purpose, I set wrong parameter name $sta8tus to format an environment for creating the error.