我在CodeIgniter中有这个查询:
$user_data = $this->db
->select('table_users.id AS user_id, table_users.email AS user_email, table_users.GUID as user_guid, '
. 'table_roles.slug AS role_slug, table_user_settings.username, table_users.id_roles, '
. 'table_users.first_name, table_users.last_name, table_users.mobile_number, table_users.phone_number, '
. 'table_users.address, table_users.city, table_users.state, table_users.zip_code, table_users.notes')
->from('table_users')
->where('table_users.data', 0)
->join('table_roles', 'table_roles.id = table_users.id_roles', 'inner')
->join('table_user_settings', 'table_user_settings.GUID = table_users.GUID')
->where('table_user_settings.username', $username)
->where('table_user_settings.password', $password)
->get()->row_array();
return ($user_data) ? $user_data : NULL;
我已编写此代码以进行转换:
if($stmt = $this->db->prepare("SELECT table_users.id AS user_id, table_users.email AS user_email, table_users.GUID as user_guid, "
. "table_roles.slug AS role_slug, table_users.id_roles, table_users.first_name, "
. "table_users.last_name, table_users.mobile_number, table_users.phone_number, "
. "table_users.address, table_users.city, table_users.state, table_users.zip_code, table_users.notes "
. "FROM table_users "
. "INNER JOIN table_roles ON table_roles.id = table_users.id_roles "
. "INNER JOIN table_user_settings ON table_user_settings.GUID = table_users.GUID "
. "WHERE table_users.data = 0 AND "
. "table_user_settings.username = ? AND "
. "table_user_settings.password = ? "))
{
$stmt->bind_param("ss",$username, $password);
$stmt->bind_result($id, $email, $GUID, $slug, $id_roles, $first_name, $last_name,
$mobile_number, $phone_number, $address, $city, $state, $zip_code, $notes);
$result = $stmt->execute();
$stmt->fetch();
var_dump($stmt);
}
$stmt->close();
return $result;
但我无法将一个数组中的所有变量作为第一个代码返回。有人可以帮助我进行转换吗?