Just before you get deep in your project here is an advice for you. Do it with ORM library.
For example I am doing the same thing you need with ORM library (in this case called db.php) like this:
$database->path->to->table->handler->load (\db\by('field1',$value1)->by('field2',$field2));
The complicated thing with ORMs are that they need class definitions to work with tables and many PHP developers are afraid of class definitions for their data objects. For above example to work you should have needed a class definition something like this:
namespace \path\to;
class table
{
public $field1;
public $field2;
}
And database initialization in case of db.php ORM library like this:
$database = new \db\database ('mysql:host=127.0.0.1', 'test_db', 'root', '1234');
And class attaching to database object to handle like this:
$database->add ('\path\to\table');
Additionally many ORMs have a magic method allowing you to automatically create or generate tables according your class definitions, for example db.php (http://dbphp.net) method:
$database->update();
Will create path_to_table table in your actual mysql database with 2 fields field1 and field2.
I am not sure why people should be afraid ORMs in PHP development they make life easier for everybody and give abilities not to get confused in your own code when you are working on large scale projects.
I believe sometimes this answer will save at least 1 human from future sufferings.
: D