I’m using the pg_query_params function to add values in my table vmobjects in my addvm.php page.
$query = "INSERT INTO vmobjects(guid, ipaddress, username, password, hostid, vmname, guestostype) VALUES($1, $2, $3, $4, $5, $6,
$7)";
$result = pg_query_params($conn, $query, array($guid, $ip, $username, $password, $hostid, $name, strtolower($os)));
Now I’m using pg_fetch_array for fetch the row in an array.
I’m using this query:
$query = "select vmname, guid, hostid, guestosname from vmobjects";
AddLog("infrastructure.php", "Query: ".$query, ERR_DEBUG_LOW);
$result = pg_query($conn, $query);
$no_records = pg_num_rows($result);
$j = $no_records;
$i = 0;
while($row = pg_fetch_array($result))
{
if($row[3] == "")
{
$vmobj_Array[$i] = $row[0] . '***' . $row[1] . '***' . $row[2];
}
else
{
$vmobj_Array[$i] = $row[0] . ' ( ' . $row[3] . ' )' . '***' . $row[1] . '***' . $row[2];
}
$i++;
}
But it is working only for a simple string like james, helton, discovere, not for j'ames, h'elton, d'iscovere.
Actually I want to fetch the row in both formats.
Use this: