+ All Categories
Home > Technology > Options Database Storage PHP

Options Database Storage PHP

Date post: 05-Dec-2014
Category:
Upload: prodigyview
View: 1,521 times
Download: 2 times
Share this document with a friend
Description:
Learn how to store and retrieve miscellaneous data into the database.
13
Options
Transcript
Page 1: Options Database Storage PHP

Options

Page 2: Options Database Storage PHP

Overview

Objective

Learn how to use the options for storing and retrieving data.

Requirements

ProdigyView with an installed and accessible

Estimated Time

10 Minutes

www.prodigyview.com

Page 3: Options Database Storage PHP

Follow Along With Code Example

1. Download a copy of the example code at www.prodigyview.com/source.

2. Install the system in an environment you feel comfortable testing in.

3.Proceed to examples/util/Options.php

Page 4: Options Database Storage PHP

What are options?Options is a type of storage that stores information in the database based upon one or more keys.

Options are great for when you want to store miscellaneous data or data that might not fit into the normal schema design.

Options are tightly integrated to ProdigyView and can be assigned to a user, a specific content, or an application.

Page 5: Options Database Storage PHP

Adding An Option

Adding an option will create a unique option. Remember to pass the value you want to store in the option in the option_value.

Page 6: Options Database Storage PHP

Setting An OptionSetting an option and adding an option are different commands. Adding an option will create a unique option. Setting an option will update or create a value in the database defined by specific parameters.

1. Parameters

2. Value

3. Set the option

Page 7: Options Database Storage PHP

Adding vs Setting Visual

New Option

New Option

New Option

Empty Slot

Empty Slot

Empty Slot

Option Placed

Empty Slot

Empty Slot

Empty Slot

PVTools::addOption

PVTools::addOption

PVTools::addOption

PVTools::setOption

PVTools::setOption

PVTools::setOption

Method Called Database

The visual below assumes that the parameters passed in each method are the same.

Page 8: Options Database Storage PHP

Set Option to UpdateUsing the setOption method, we can update an options current value if the other parameters passed are the same. Changing on of the parameters will create a new option.

Keep the same parameters to update

Update option_value with new data

Page 9: Options Database Storage PHP

Iterate and UpdateIf we used the addOption method, there might be instances where we have multiple options with the same parameters. We can retrieve those by iterating through the options. The getOptionList() follows the PV Standard Search Query arguments.

1. Get the option list of all the options currently stored

2. Update the option by passing it back through

Page 10: Options Database Storage PHP

Updating the optionLooking closer at the options retrieved from the database on the last slide, the list is an array of arrays. When updating an option, it is important to pass that array back with the changed values in the updateOption method.

3. Update the option by passed it back through

1. Iterate through the array of arrays

2. Set a new value in the field in the option

Page 11: Options Database Storage PHP

Searching

One of the things we can do is specify the parameters to search for. Using the syntax in a PV Standard Search Query, we can narrow the options retrieved.

Search only for the option with type as coffee

Page 12: Options Database Storage PHP

Deleting

The last step is deleting an option. In order to do so, you must have the option_id and pass it to the method deleteOption.

Delete the option by it’s id

Page 13: Options Database Storage PHP

API ReferenceFor a better understanding of the tools and options, visit the api by clicking on the link below.

PVTools

www.prodigyview.com

More Tutorials

For more tutorials, please visit:

http://www.prodigyview.com/tutorials


Recommended