Jump to content

Recommended Posts

Will this code (not including XSS) prevent all malicious changes/deleting in a database, such as SQL Injection? I just want to be sure this code is the best I can make it.

 

/*
     * @METHOD  processInsertQuery
     * @DESC    prepares a query for use, then runs it
     */
    
    
    
    public function processQuery($query, array $binds, $fetch)
    {
        $query_handle = $this->dbc->prepare($query);
        if(!$query_handle->execute($binds))
        {
            $error = $query_handle->errorInfo();
            echo $error[2];
}
        
        //update insertId var
        $this->insertId = $this->dbc->lastInsertId();
        
        //incase we ever want to get the number of rows affected
        //we set our row_count variable to the number of rows
        //affected
        $this->row_count = $query_handle->rowCount();
        
        if($fetch == true)
        {
            return $query_handle->fetchAll();
        }
    }

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.