#4 Suggestion: more shortcuts

closed
nobody
None
5
2002-08-04
2002-02-16
Anonymous
No

Having used PHPlib since v5? I 'd like to suggest
some addtions to the DB wrapper classes since I
use these almost exclusively now:

/* query->fetch, a onestep shortcut for single row
queries
returns the number of rows so it can be used in if
statements */
function qf($query) {
$this->query($query);
$this->next_record();
return $this->num_rows();
}

/* query - make the query, return the number of
rows */
function numquery($query) {
$this->query($query);
return $this->num_rows();
}

/* returns number of affected rows after the query
is made
can be used in if statements true/false */
function truequery($query) {
$this->query($query);
return $this->affected_rows();
}

/* returns queryID after the query is made - Silent
suppresses
any mysql errors */
function silentquery($query) {
$this->Silent=1;
$this->query($query);
return $this->Query_ID();
}

/* returns queryID affter the query is made */
function lockquery($query, $table) {
$this->lock($table);
$this->query($query);
$this->unlock();
return $this->affected_rows();
}

/* returns the 'fetch array' row - handy for sinlge
'gets'*/
function getRow() {
$this->next_record();
return $this->Record;
}

Discussion

  • Ignatius Teo

    Ignatius Teo - 2002-08-04

    Logged In: YES
    user_id=29397

    Thank you for your contributions, we will shortly be reviewing
    v7.4x in light of future developments for v8 and if warranted,
    we may include your suggestions in the distro.

     
  • Ignatius Teo

    Ignatius Teo - 2002-08-04
    • status: open --> closed
     

Log in to post a comment.