Fork me on GitHub
Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
New Posts New Topics All Posts All Forums Index General Modules Themes Development International XOOPS.org

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

- 2 2.5 2.6 4 6 Abuse adslight Android AntiHarvesting AntiSpam Apple Battlefield billige Blocks Bootstrap Captcha cell cent chronolabs Clicks content CĂN demo docek download Dresses evden eve facebook Fat floor for free Gateway Google Guide herre Home Honeypot HP html5 Human HỘ IP iPhone jQuery List log Loss module modules Monster new newbb news NHÀ online PARK phone PHP Prevention profile project Protector publisher Rapid RESIDENCE responsive review Rights rmcommon Room security Sentry site Smartphone Smarty Smoking Spam stem Studio support tag tags tdmcreate template The Theme themes User userlog web weight xoops Xortify XPayment ZendFramework

New Users

Registering user

# 137302

neely

Welcome to XOOPS!




Bottom   Previous Topic   Next Topic  Register To Post



#1 Posted on: 2012/4/23 5:37 xoops classes
Hi everyone.I am using xoops classes for the 1st time and it seems like I am not getting it right. I am creating a simple program to insert data into a table called capture_information. This is my code:


//for index.php
<?php

require('../../mainfile.php');

global 
$xoopsOption;

$xoopsOption['template_main']= 'main.html';

require(
XOOPS_ROOT_PATH.'/header.php');

//////

$op '';

if(isset(
$_POST['save'])){

$op 'save';

}



if(isset(
$_POST['delete'])){

$op 'delete';

}

 

switch(
$op){



case 
'delete':


echo 
'why u wana delete?';



case 
'save':

 



$record_handler =& xoops_getModuleHandler('records','record');

$record_id $_POST['record_id'];

        if(
$record_id == 0){

            
//

            
$recordObj $record_handler->create();

        }

        else{

            
//

        
$recordObj $record_handler->get($record_id);

}

{

        
$recordobj->setVar("name",$_POST['name']);

        
$recordobj->setVar("email"$_POST['email']);

        
$recordobj->setVar("telephone"$_POST['telephone']);

        
$recordobj->setVar("address"$_POST['address']);

        
$recordobj->setVar("areacode"$_POST['areacode']);

        
$recordobj->setVar("time"time()); 

        
$recordobj->setVar("user_id"$GLOBALS['xoopsUser']->getVar("uid"));

}



if(!(
$record_handler->insert($recordObj)))

{

            
redirect_header(XOOPS_URL,2,'Error saving record');}

break;

}

require(
XOOPS_ROOT_PATH.'/footer.php');

?>


//for the class called record under a module called record

<?php
if (!defined("XOOPS_ROOT_PATH")) {
    die(
"XOOPS root path not defined");
}

class 
RecordRecord extends XoopsObject {

    function 
RecordRecord() {
        
$this->__construct();
    }

    function 
__construct() {
                
$this->initVar("record_id"XOBJ_DTYPE_INTnullfalse);
                
$this->initVar('name'XOBJ_DTYPE_TXTBOXnullfalse);
                
$this->initVar('email'XOBJ_DTYPE_TXTBOXnullfalse);
                
$this->initVar("telephone",  XOBJ_DTYPE_TXTBOXnullfalse255);
                
$this->initVar('address'XOBJ_DTYPE_TXTBOXnullfalse);
                
$this->initVar("areacode"XOBJ_DTYPE_TXTBOX0false);
                
$this->initVar("time"XOBJ_DTYPE_INT0false);
                
$this->initVar("user_id"XOBJ_DTYPE_INTnullfalse15);
    }    
}

class 
RecordRecordsHandler extends XoopsPersistableObjectHandler {

var 
$recordList;


    function 
RecordRecordsHandler(&$db
{
        
$this->__construct($db);
    }

    function 
__construct(&$db) {
        
parent::__construct($db'capture_information''RecordRecord''record_id');
}
?>

when i click the save button it shows me a blank page.plz help

Top

cyree
Just popping in
Just popping in
Joined:
2012/3/26 4:30
From Sandton South Africa
Group:
Registered Users
Posts: 2
(Show More) (Show Less)


#2 Posted on: 2012/4/23 12:07 Re: xoops classes
cyree,

Please see http://xoops.org/modules/newbb/viewto ... id=345955#forumpost345955 for an example. Your code above has some of the same issues as the code in that post.

Make sure you put your classes in the right folder/file too. In some places you use 'records' for your class name and in others it's 'record'. That will need to be corrected too...

Top

zyspec
Module Developer
Module Developer
Joined:
2004/9/21 8:28
From USA
Group:
Registered Users
Posts: 871
(Show More) (Show Less)


#3 Posted on: 2012/4/24 9:20 Re: xoops classes
Thanx,I managed to fix those errors. The problem was with calling the functions from class in index.

Top

cyree
Just popping in
Just popping in
Joined:
2012/3/26 4:30
From Sandton South Africa
Group:
Registered Users
Posts: 2
(Show More) (Show Less)







You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You can vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.

[Advanced Search]