How can i add Unlimited depth category, sub-category and items - categories

How can I add unlimited depth category, sub-category and items by using Codeigniter?
Category 1
-Sub cat
-Sub cat
--Sub sub cat
--- Sub sub cat
-- Sub sub cat
-Sub cat Category 2
-Sub cat
-Sub cat
--Sub sub cat
---sub sub sub cat
----sub sub sub sub cat
-sub cat Category 3
-Sub cat
I need my SQL database and PHP code or Codeigiter code to add records to the database.

Create Table
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(37) COLLATE utf8_unicode_ci NOT NULL,
`parentid` int(11) DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `parentid_fk` (`parentid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
INSERT INTO `categories` (`id`, `name`, `parentid`) VALUES
(1, 'animal', 0),
(2, 'vegetable', 0),
(3, 'mineral', 0),
(4, 'doggie', 1),
(5, 'kittie', 1),
(6, 'horsie', 1),
(7, 'gerbil', 0),
(8, 'birdie', 1),
(9, 'carrot', 2),
(10, 'tomato', 2),
(11, 'potato', 2),
(12, 'celery', 2),
(13, 'rutabaga', 2),
(14, 'quartz', 3),
(15, 'feldspar', 3),
(16, 'silica', 3),
(17, 'gypsum', 3),
(18, 'hunting', 4),
(19, 'companion', 4),
(20, 'herding', 4),
(21, 'setter', 18),
(22, 'terrier', 18),
(23, 'poodle', 19),
(24, 'chihuahua', 19),
(25, 'shepherd', 20),
(26, 'collie', 20);
php Code
// $current_cat_id: the current category id number
// $count: just a counter, call it as 0 in your function call and forget about it
/* GET THE DROP DOWN LIST OF CATEGORIES */
function get_cat_selectlist($current_cat_id, $count, $lastname='') {
static $option_results;
// if there is no current category id set, start off at the top level (zero)
if (!isset($current_cat_id)) {
$current_cat_id=1;
}
// increment the counter by 1
$count = $count+1;
// query the database for the sub-categories of whatever the parent category is
$sql = "SELECT id, name from categories where parentid = ".$current_cat_id." order by name asc";
$get_options = mysql_query($sql);
$num_options = mysql_num_rows($get_options);
// our category is apparently valid, so go ahead €¦
if ($num_options > 0) {
while (list($cat_id, $cat_name) = mysql_fetch_row($get_options)) {
// if its not a top-level category, indent it to
//show that its a child category
if ($current_cat_id!=0) {
$indent_flag = $lastname . '--';
// for ($x=2; $x<=$count; $x++) {
$indent_flag .= '>';
// }
}
$cat_name = $indent_flag.$cat_name;
$option_results[$cat_id] = $cat_name;
// now call the function again, to recurse through the child categories
get_cat_selectlist($cat_id, $count, $cat_name);
}
}
return $option_results;
}
echo '<select name="cat_id">';
echo '<option value="">-- Select -- </option>';
$get_options = get_cat_selectlist(0, 0);
if (count($get_options) > 0){
$categories = $_POST['cat_id'];
foreach ($get_options as $key => $value) {
$options .="<option value=\"$key\"";
// show the selected items as selected in the listbox
if ($_POST['cat_id'] == "$key") {
$options .=" selected=\"selected\"";
}
$options .=">$value</option>\n";
}
}
echo $options;
echo '</select>';
Output will be

in add.php page
<?php
//---------------------------
//By MF alraii 2017
//aseer333#hotmail.com
//mfalraii#gmail.com
//لا تنسونا من صالح الدعاء
//---------------------------
error_reporting(E_ALL);
ini_set('display_errors', 1);
$db_hostname = "localhost";
$db_username = "";
$db_password = "";
$db_dbname = "";
$link = false;
Connect($db_hostname,$db_username,$db_password,$db_dbname);
function Connect($db_hostname,$db_username,$db_password,$db_dbname) {
global $link;
$link = mysqli_connect($db_hostname,$db_username,$db_password,$db_dbname);
// اختبار الاتصال
if (mysqli_connect_errno())
{
die("خطأ في الاتصال: " . mysqli_connect_error());
}
}
function get_cat_selectlist($current_cat_id, $count, $lastname='') {
global $link;
static $option_results;
// اذا لم يكن هناك مجموعه معرفه سابقا يبدأ من هنا
if (!isset($current_cat_id)) {
$current_cat_id=1;
}
// زيادة العداد برقم 1
$count = $count+1;
// استعلام قاعدة البيانات للفئات الفرعية مهما كانت الفئة الأم
$sql = "SELECT id, name from categories where parentid = ".$current_cat_id." order by name asc";
$get_options = mysqli_query($link, $sql);
$num_options = mysqli_num_rows($get_options);
// وضع القسم في المكان المناسب له في الشجرة
if ($num_options > 0) {
while (list($cat_id, $cat_name) = mysqli_fetch_row($get_options)) {
// اذا تم حذف القسم الاساسي ولم يوجد
//اظهر هذا في القسم الابن او القسم الفرعي
if ($current_cat_id!=0) {
$indent_flag = $lastname . '--';
$indent_flag .= '>';
}
$cat_name = $indent_flag.$cat_name;
$option_results[$cat_id] = $cat_name;
// الان استدعاء الدالة مرة اخرى واعادة بناء القسم الجديد في موقعه الصحيح
get_cat_selectlist($cat_id, $count, $cat_name);
}
}
return $option_results;
}
// اختبار اذا كان هناك قسم جديد مسجل لادراجه في شجرة او تفرعات الاقسام
if (isset($_POST["new_cat_name"])) {
global $link;
$new_cat = $_POST["new_cat_name"];
$parent = $_POST["cat_id"];
$sql = "INSERT INTO categories (`id`, `name`, `parentid`) VALUES (NULL, '$new_cat', '$parent')";
mysqli_query($link, $sql);
echo "التصنيف الجديد باسم : '$new_cat'قد تمت اضافته للاقسام!<br><br>";
}
echo '<form action="add.php" method="post">';
echo '<label>تصنيف جديد باسم: </label> <input type="text" name="new_cat_name"></input><br><br>';
echo '<label>التصنيف الاساسي: </label>';
echo '<select name="cat_id">';
echo '<option value="0">-- قسم جديد -- </option><br><br>';
$get_options = get_cat_selectlist(0, 0);
if (count($get_options) > 0){
$categories = $_POST['cat_id'];
foreach ($get_options as $key => $value) {
$options .="<option value=\"$key\"";
// عرض العنصر المحدد كما تم تحديدة في القائمة
if ($_POST['cat_id'] == "$key") {
$options .=" selected=\"selected\"";
}
$options .=">$value</option>\n";
}
}
echo $options;
echo '</select><br><br>';
echo '<input type="submit" value="اضافة قسم جديد"></input></form>';
?>
and in index.php page
<?php
//---------------------------
//By MF alraii 2017
//aseer333#hotmail.com
//mfalraii#gmail.com
//لا تنسونا من صالح الدعاء
// الكود كاملا وأشمل في صفحة add.php
//صفحة الاندكس فقط لعرض النتيجة
//---------------------------
$db_hostname = "localhost";
$db_username = "";
$db_password = "";
$db_dbname = "";
Connect($db_hostname,$db_username,$db_password,$db_dbname);
function Connect($db_hostname,$db_username,$db_password,$db_dbname) {
global $link;
$link = mysqli_connect($db_hostname,$db_username,$db_password,$db_dbname);
// اختبار الاتصال
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
}
function get_cat_selectlist($current_cat_id, $count, $lastname='') {
global $link;
static $option_results;
// اذا لم يكن هناك مجموعه معرفه سابقا يبدأ من هنا
if (!isset($current_cat_id)) {
$current_cat_id=1;
}
// زيادة العداد برقم 1
$count = $count+1;
// استعلام قاعدة البيانات للفئات الفرعية مهما كانت الفئة الأم
$sql = "SELECT id, name from categories where parentid = ".$current_cat_id." order by name asc";
$get_options = mysqli_query($link, $sql);
$num_options = mysqli_num_rows($get_options);
// وضع القسم في المكان المناسب له في الشجرة
if ($num_options > 0) {
while (list($cat_id, $cat_name) = mysqli_fetch_row($get_options)) {
// اذا تم حذف القسم الاساسي ولم يوجد
//اظهر هذا في القسم الابن او القسم الفرعي
if ($current_cat_id!=0) {
$indent_flag = $lastname . '--';
$indent_flag .= '>';
}
$cat_name = $indent_flag.$cat_name;
$option_results[$cat_id] = $cat_name;
// الان استدعاء الدالة مرة اخرى واعادة بناء القسم الجديد في موقعه الصحيح
get_cat_selectlist($cat_id, $count, $cat_name);
}
}
return $option_results;
}
echo '<select name="cat_id">';
$get_options = get_cat_selectlist(0, 0);
if (count($get_options) > 0){
$categories = $_POST['cat_id'];
foreach ($get_options as $key => $value) {
$options .="<option value=\"$key\"";
// عرض العنصر المحدد كما تم تحديدة في القائمة
if ($_POST['cat_id'] == "$key") {
$options .=" selected=\"selected\"";
}
$options .=">$value</option>\n";
}
}
echo $options;
echo '</select>';
and in database
sql file import
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+03:00";
CREATE TABLE `categories` (
`id` int(11) NOT NULL,
`name` varchar(37) COLLATE utf8_unicode_ci NOT NULL,
`parentid` int(11) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `categories` (`id`, `name`, `parentid`) VALUES
(1, 'animal', 0),
(2, 'vegetable', 0),
(3, 'mineral', 0),
(4, 'doggie', 1),
(5, 'kittie', 1),
(6, 'horsie', 1),
(7, 'gerbil', 0),
(8, 'birdie', 1),
(9, 'carrot', 2),
(10, 'tomato', 2),
(11, 'potato', 2),
(12, 'celery', 2),
(13, 'rutabaga', 2),
(14, 'quartz', 3),
(15, 'feldspar', 3),
(16, 'silica', 3),
(17, 'gypsum', 3),
(18, 'hunting', 4),
(19, 'companion', 4),
(20, 'herding', 4),
(21, 'setter', 18),
(22, 'terrier', 18),
(23, 'poodle', 19),
(24, 'chihuahua', 19),
(25, 'shepherd', 20),
(26, 'collie', 20),
(27, 'test1111', 5),
(28, 'testmf', 5),
(29, 'testmof', 1);
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `id` (`id`),
ADD KEY `parentid_fk` (`parentid`);
ALTER TABLE `categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30;
ولا تنسونا من صالح الدعاء

Related

Magento 2 - Update Product stock and Price Programmatically for multiple stores

I'm getting data from the CSV file and according to SKU file load the product.
We are getting 30 products from the CSV file and update those product data in Magento.
We have set up cron every 5 minutes and after 5 minutes it will get the next 30 products and update.
The starting process script is working fine. But after the sometime script is going to be slow and it will take time to update the product.
So, the next cron is running at on the same time there are lots of scripts are running on the server, and the server load will increase.
After taking so much load on the server website going to be slow.
Can you please let me know the way so product updating process will be consistent and time will not so much vary.
public function execute()
{
$data = array of csv file data;
$sql = "Select value FROM " . $tableName . " where path='catalog/product/update_cron' and scope_id=0";
$result = $connection->fetchAll($sql);
$update_cron = $result[0]['value'];
$total_products = count($data);
if ($total_products == $update_cron) {
$this->configWriter->save('catalog/product/update_cron_status', '1', 'default', '0'); // inject Magento\Store\Model\ScopeInterface;
exit;
}
if ($update_cron != '' && $update_cron != 0) {
$data = array_slice($data, (int)$update_cron, 30);
} else {
$update_cron = 0;
$data = array_slice($data, 0, 30);
}
$current_date = date("m/d/Y");
$i = 0;
foreach ($data as $key => $value) {
/*********************************************Update Product Price********************************************************/
if ($value['Artikel'] != '') {
$product = $objectManager->create('Magento\Catalog\Model\Product');
$product_id = $product->getIdBySku($value['Artikel']);
if (!empty($product_id)) {
/************************Update Product Price for all Stores**************************************/
$price_b2b = str_replace(',', '.', (string) $value['Verkoopprijs']);
$price_b2c = str_replace(',', '.', (string) $value['Numeriek1']);
$price_club = str_replace(',', '.', (string) $value['Numeriek2']);
//$special_price_b2b = str_replace(',', '.', (string) $value['Numeriek3']);
$productActionObject = $objectManager->create('Magento\Catalog\Model\Product\Action');
$productActionObject->updateAttributes(array($product_id),
array(
'name' => $value['Artikel'],
'ean_code'=>$value['Barcode'],
'price'=>$price_b2c,
'price_wholesale'=>$price_b2b,
'price_clubs'=>$price_club,
'description'=>$value['Omschrijving Engels'],
),0
);
/* if ($value['Boolean1'] == 'True') {
$objectManager->create('Magento\Catalog\Model\Product\Action')->updateAttributes(array($product_id), array('price' => $price_b2b, 'special_price' => $special_price_b2b, 'special_from_date' => $current_date), 4);
} else { */
$objectManager->create('Magento\Catalog\Model\Product\Action')->updateAttributes(array($product_id), array('price' => $price_b2b, 'special_price' => '', 'special_from_date' => ''), 4);
//}
$objectManager->create('Magento\Catalog\Model\Product\Action')->updateAttributes(array($product_id), array('price' => $price_club), 7);
/*********************************************Inventory Update********************************************************/
$stockRegistry = $objectManager->create('Magento\CatalogInventory\Api\StockRegistryInterface');
$sku = $value['Artikel'];
if($sku != '')
{
$qty = round(str_replace(',', '', (string) $value['Stock']));
$stockItem = $stockRegistry->getStockItemBySku($sku);
$stockItem->setQty($value['Stock']);
$stockItem->setIsInStock((int) ($qty > 0)); // this line
$stockRegistry->updateStockItemBySku($sku, $stockItem);
}
/*****************************************************************************************************/
}
$i++;
$update_val = $update_cron + $i;
$this->configWriter->save('catalog/product/update_cron', $update_val, 'default', 0);
}
else {
$i++;
$update_val = $update_cron + $i;
$this->configWriter->save('catalog/product/update_cron', $update_val, 'default', 0);
}
}
die('records completed');
}
}
die('stop');
}
Thanks in advance

Get loop text values from mform

Mmform has a 'count' textfield. When user has filled with value 3, mform should create 'Unit part' by looping the textfields
(forename, designation and filemanager). Upon mform submission, I need to display Unit part filled by the user.
Could you let me know suggestions.
<?php
require('config.php');
require_once($CFG->libdir.'/formslib.php');
class active_form extends moodleform {
function definition() {
$mform = $this->_form;
$fileoptions = $this->_customdata['fileoptions'];
$count = $mform->addElement('text', 'count', get_string('count', 'form'), array('name' => 'count[]');
$count = $mform->setType('count', PARAM_INT);
for ($i=1; $i<=$count; $i++) {
// Unit
$mform->addElement('text', 'forename', get_string('forename', 'form'), array('name'=>'forename[]'));
$mform->setType('forename', PARAM_RAW);
$mform->addElement('text', 'designation', get_string('designation', 'form'), array('name'=>'designation[]'));
$mform->setType('designation', PARAM_RAW);
$mform->addElement('filemanager', 'attachment', get_string('attachment', 'form'), null, $fileoptions);
$mform->setType('attachment', PARAM_RAW);
}
$this->add_action_buttons();
}
function validation($data, $files) {
$errors = parent::validation($data, $files);
return $errors;
}
}
$mform = new active_form(null, $customdata);
if ($mform->is_submitted()) {
$data = $mform->get_data();
for ($i=1; $i <= $data->count; $i++) {
$forename = $data->forename;
$designation = $data->designation;
$attachment = $data->attachment;
echo 'forename' . $forename. '<br>';
echo 'designation' . $designation. '<br>';
echo 'attachment' . $attachment. '<br>';
}
}
echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();
?>
ex: User has filled with
count: 3
forename = SVs Group
designation = Assistant Engineer
attachment = 676208496
forename = Prime Group
designation = Staff Member
attachment = 646759033
forename = Ecos Group
designation = Staff Member
attachment = 107025147
Output:
count:3
forename: SVs Group
designation: Assistant Engineer
attachment: 676208496
forename: Prime Group
designation: Staff Member
attachment: 646759033
forename: Ecos Group
designation: Staff Member
attachment: 107025147

Gravity Forms - Get a Date value and adjust it, make it into a merge tag

So what I want to be able to do is take a field value, a date field, and add a set period of time to it and then make that into a merge tag that I can then add back into that value or use else where.
I know how to make a new merge tag, that's not the issue. My question is how do I get a field value to use in that calculation?
add_filter( 'gform_replace_merge_tags', 'new_date_plus_30', 10, 7 );
function new_date_plus_30( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
$merge_tag = '{date_plus_30}';
$new_date = date('m/d/Y', strtotime('+30 days'));
return str_replace( $merge_tag, $new_date, $text );
}
So where I do the new date calculation, I need to be able to pull in a field from that post and use it.
I was also thinking of doing a If / Else script where I would do the date calculation based on what was set in a form. So if a user said repeat this every 15 days, I would have something like:
add_filter( 'gform_replace_merge_tags', 'new_date_plus_30', 10, 7 );
function new_date_plus_30( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
if ( $form_id == 34 && $field_id == 2 && $value == 'add 30 days') {
$merge_tag = '{date_plus_30}';
$new_date = date('m/d/Y', strtotime('+30 days'));
}
else if ( $form_id == 34 && $field_id == 2 && $value == 'first of month') {
$merge_tag = '{first_of_month}';
$new_date = date('m/d/Y', strtotime('first of next month'));
}
}
return str_replace( $merge_tag, $new_date, $text );
}
But my issue is still the same. How can I use two filters at the same time? I assume I need to use the gform_get_input_value. Kindly review my code and give feedback is there other way?
Or maybe something like this...
add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $options, $field, $raw_value ) {
if ( $field->id == '2' && $value == 'first of the month') {
$merge_tag = '{the_next_date}';
$thedatetochange = 'Not sure how to get the date value here...';
$value = date('m/d/Y', strtotime($thedatetochange . 'first of the next month'));
return $value;
}
else if ( $field->id == '2' && $value == 'the 15th') {
$merge_tag = '{the_next_date}';
$thedatetochange = 'Not sure how to get the date value here...';
$the_first_date = date('m/d/Y', strtotime($thedatetochange . 'first of the next month' ));
$value = date('m/d/Y', strtotime($the_first_date . '+15 days' ));
return $value;
}
}, 10, 5 );
So after doing more digging, would I be able to use something like this to get the value of the field?
$theDateToChange = rgar( $entry, ‘3’);
This assumes that the field 3 is a date value. Would this work for retrieving the current entry date?
The $entry is passed through the gform_replace_merge_tags filter. You can fetch any field value from the $entry by its field ID. For example, if your field ID was 1:
$value = $entry[1];
Alternately, if you're open to capturing this modified date as a secondary Date field in your form, we have a snippet that can handle the functionality for you.
https://gravitywiz.com/populate-dates-gravity-form-fields/
new GW_Populate_Date( array(
'form_id' => 1,
'target_field_id' => 2,
'modifier' => '+30 days'
) );
So here is my current working code...
add_action( 'gform_admin_pre_render', 'add_merge_tags' );
function add_merge_tags( $form ) {
?>
<script type="text/javascript">
gform.addFilter('gform_merge_tags', 'add_merge_tags');
function add_merge_tags(mergeTags, elementId, hideAllFields, excludeFieldTypes, isPrepop, option){
mergeTags["custom"].tags.push({ tag: '{the_next_date}', label: 'The Next Date' });
return mergeTags;
}
</script>
<?php
//return the form object from the php hook
return $form;
}
add_action('wp', 'add_merge_tags');
/** MY MERGE TAGS HERE */
add_filter( 'gform_replace_merge_tags', 'new_date', 10, 7 );
function new_date( $value, $merge_tag, $options, $field, $raw_value, $entry, $text, $form, $url_encode, $esc_html, $nl2br, $format ) {
$pmoptions = $entry[7];
if ( $pmoptions == 'Monthly') {
$merge_tag = '{the_next_date}';
$old_date = $entry[2];
$new_date = date('m/d/Y', strtotime( $old_date . '+1 month'));
return str_replace( $merge_tag, $new_date, $text );
}
else if ( $pmoptions == 'Quarterly') {
$merge_tag = '{the_next_date}';
$old_date = $entry[2];
$new_date = date('m/d/Y', strtotime( $old_date . '+3 month'));
return str_replace($merge_tag, $new_date, $text);
}
}
apply_filters( 'gform_replace_merge_tags', $value, $merge_tag, $options, $field, $raw_value, $entry, $text, $form, $url_encode, $esc_html, $nl2br, $format );

Query where substr Codeigniter

I have to check two characters of a string in the database.
here is my code but it does not work.
function getby_substr() {
$query = $this->db
->where('substr(ipv6, 4,2 )', 'c1')
->get('computer_information');
if ($query->num_rows() > 0) {
return $query->result();
}
return array();
}
Thank you,
Hope this helps you :
With where clause
/*replace column_name with your table field name*/
$query = $this->db
->where('column_name', SUBSTRING(ipv6, 2, 5))
->get('computer_information');
With like clause
$query = $this->db
->like('column_name', SUBSTRING(ipv6, 2, 5))
->get('computer_information');
for more : https://www.codeigniter.com/user_guide/database/query_builder.html#selecting-data

Add several records in moodle

I've been having trouble adding items in my table in moodle, this is what I've trying with no success.
$totalrec = array();
$rec2 = $DB->get_records('table1', null, '', '*', 0, 0);
$rec4 = $DB->get_records('table2', array('x' => 'y') , '', '*', 0, 0);
foreach ($rec2 as $records2) {
$rec3 = $DB->get_records('z', array('m' => 'n') , '', '*', 0, 0);
foreach ($rec3 as $records3) {
if (isset($_REQUEST['a']) && isset($_REQUEST['b'])) {
$ca = $_REQUEST['a'];
$co = $_REQUEST['b'];
$pi = $records2->idp;
$recorsh = new class ();
$recorsh->id = $records2->id;
$recorsh->te = $co;
$recorsh->idt = $ti;
$recorsh->res = $ca;
$recorsh->ida = $idaud;
$totalrec[$n] = array($recorsh);
$n++;
}
}
}
$lastinsertid2 = $DB->insert_records('table4', $totalrec);
and, this one:
$rec2 = $DB->get_records('table1', null, '', '*', 0, 0);
$rec4 = $DB->get_records('table2', array('x' => 'y') , '', '*', 0, 0);
foreach($rec2 as $records2) {
$rec3 = $DB->get_records('z', array('m' => 'n') , '', '*', 0, 0);
foreach($rec3 as $records3) {
if (isset($_REQUEST['a']) && isset($_REQUEST['b'])) {
$ca = $_REQUEST['a'];
$co = $_REQUEST['b'];
$pi = $records2->idp;
$recorsh = new class ();
$recorsh->id = $records2->id;
$recorsh->te = $co;
$recorsh->idt = $ti;
$recorsh->res = $ca;
$recorsh->ida = $idaud;
$lastinsertid = $DB->insert_record('table4', $recorsh, false);
}
}
}
Both of them gives me a "Error writing to database" but doesn't say anything specific, I know that I'm not doing the inserting "in the right way" but I don't know how to do it, what am I doing wrong?
It's probably because the ID is added to each object before inserting.
$recorsh->id = $records2->id;
Like davosmith says, during development always have debugging set to developer level.
In your config.php have this
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 0);
$CFG->debug = E_ALL | E_STRICT; // 32767;
$CFG->debugdisplay = true;
Also never ever use $_REQUEST or $_GET or $_POST directly. This can introduce SQL injection.
Use
$a = optional_param('a', null, PARAM_XXX);
$b = optional_param('b', null, PARAM_XXX);
or
$a = required_param('a', PARAM_XXX);
$b = required_param('b', PARAM_XXX);
Change PARAM_XXX to the type of parameter you are expecting. eg PARAM_INT, PARAM_BOOL etc.