SkillAgentSearch skills...

SQLHelper

This is a helping class for the users of PHP with SQL in which the user can only use bind_result()! This makes it easier to use!

Install / Use

/learn @JaredScar/SQLHelper
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

SQLHelper

License: MIT

Hey welcome to SQLHelper, a PHP SQL class made for people who don't have access to the MySQLi function get_result, but have access to MySQLi bind_result only. Everyone is free to use this. Just please give credit where credit is due and share the resource so others can have the pleasure of using it! Thanks for checking it out!

How does it work?

Great question dude! The way it works is quite simple. Here are some examples and explanations :)

Declaring the helper

$helper = new SQLHelper('localhost', 'BadgerDev', 'password', 'flooddb', 3306);

Preparing Statement

$helper->prepare("SELECT city FROM usa WHERE state = ?");

Binding params

$helper->bindParams("s", "Wyoming");

Handling execution

if($helper->execute()) { /* Returns boolean dependent on if it was executed without error */ 
}

Getting number of rows

$helper->num_rows // Can only be ran after execute() function ran

Looping through Associative Array

while ($row = $helper->get_both_array_results()) {
        echo 'The city is: ' . $row['city'];
    }

SQL Objects:


Looping through SQL Object

while($row = $helper->get_results_as_objs()) {
    echo 'One of the IDs to the query is: ' . $row->id;
}

Getting the single SQL Object

$helper->get_sql_obj()->id; // This is the ID column value of query

Related Skills

View on GitHub
GitHub Stars4
CategoryData
Updated5y ago
Forks0

Languages

PHP

Security Score

70/100

Audited on Oct 26, 2020

No findings