simpleAdminPlus v1.0

simpleAdminPlus Core

Click on a function to expand it.

get_rows() $simpleAdmin->get_rows()
get_rows() – Gets all rows from a specified table.

Usage

$simpleAdmin->get_rows( [table_name], [order_by], [limit] )
table_name string (required)
Chooses the table and will select all the columns from it.
order_by string (default=id)
This will append ORDER BY `id` to the end of the query. If you want to select with the where clause you can supply WHERE `category_id` = '2' ORDER BY `id`
limit integer (default=0)
This will limit the query to however many rows you want. If the number is set to zero it will select all rows without a limit.

Example

<?php $products = $simpleAdmin->get_rows('products', '', 2) ?>
<?php foreach( $products as $product ) : ?>
	<h2><?= $product->title ?></h2>
<?php endforeach ?>

Example (With Paging)

<?php $products = $simpleAdmin->get_rows('products', '', 2) ?>
<?php foreach( $products as $product ) : ?>
	<h2><?= $product->title ?></h2>
<?php endforeach ?>

// Create three links, and change the previous and next link's text
<?php $simpleAdmin->paging_links('products', 3, array(
	'next_text' => '>',
	'prev_text' => '<'
)) ?>

paging_links() – Creates Links for a specified table
Used with $simpleAdmin->get_rows()


Usage

$simpleAdmin->paging_links( [table_name], [num_links], [options] )
table_name string (required)
Chooses the table to create the paging links for. It requires get_rows() to create the query
num_links int (default=10)
Number of links visible at a time.
options array
This allows you to change the default text of the first, previous, next, and last links.
If the value is set to false, it will not show the link
array(
	'first_text' => false, // Don't show the first link
	'last_text' => false, // Don't show the last link
	'prev_text' => '<', // Change the previous link text to <
	'next_text' => '>', // Change the next link text to >				
)

Example

// Show ten links and change the text of the previous and next links
<?php $simpleAdmin->paging_links('products', '', array(
	'next_text' => '>',
	'prev_text' => '<'
)) ?>
extend() $simpleAdmin->extend()

extend() – Allows you to use default options, and extend those options.
This function was created to use options in simpleAdminPlus, but can be used for your own functions as well.


Usage

$simpleAdmin->extend( [options], [defaults] )
options array (required) Supplied by the user
This is a set of options supplied by the user. It does not need all the default options supplied.
defaults array (required)
This is the set of options to use if the user's options are not supplied.

Example

<?php
function say_something($options = null) {
	$default_options = array(
		'text' => 'Hello World'
	);
	
	if( is_array($options) )
		$options = $simpleAdmin->extend($options, $default_options);
	
	echo $options['text'];
}

say_something(); // echos Hello World
say_something(array(
	'text' => 'Goodbye World'
)); // echos Goodbye World
?>