This might seem unorthodox, but...
In my PHP script, I check for certain variables, and if they exist then I INSERT INTO a MySQL table (to ensure up-to-date content). Then, later in the script, I SELECT that same data back out of the table.
To get around that, I'm INSERTing, and then immediately building an array with the same data. Then later, I check to see if that array exists, and if not then I SELECT, then build the array from that data. So either way, I'm manipulating the same data several times.
So what I'm wondering is, can I manually build a resource in the INSERT section that would be identical to the result from mysql_query($sth), so I could then use mysql_fetch_row() to list it?
Something like:
if ($condition == 1) {
// get updated content
list($var1, $var2) = get_data();
$query = "REPLACE INTO table (col1, col2) VALUES ('$var1', '$var2')";
mysql_query($query);
// Build $sth manually using the same data
$sth = build_resource('$var1', '$var2');
}
if (!$sth) {
$read_query = "SELECT * FROM table";
$sth = mysql_query($read_query);
}
while(list($var1, $var2) = mysql_fetch_row($sth)) {
// do stuff
}
That's obviously just written up to give you a visual of what I'm asking... I'm just hoping to find "build_resource()" to manually build $sth using data that I already have, without a second MySQL query.