Part of the EllisLab Network
   
2 of 2
2
Using CI models outside of CI.
Posted: 30 August 2007 12:43 AM   [ Ignore ]   [ # 16 ]  
Summer Student
Total Posts:  9
Joined  04-05-2007

Can we use the built in CI library and other classes with in the amfphp service?
Please advice.

Profile
 
 
Posted: 30 August 2007 08:12 AM   [ Ignore ]   [ # 17 ]  
Summer Student
Total Posts:  26
Joined  06-19-2007

Yes, you should be able to use it no problem.  I’ve definitely used it myself.  I did notice that for some libraries, you need to set CI to autoload them instead of loading the libraries in the constructor or something like that.  Not sure if that was just a fluke though.

Profile
 
 
Posted: 01 September 2007 02:41 AM   [ Ignore ]   [ # 18 ]  
Summer Student
Total Posts:  9
Joined  04-05-2007

Can we do this, in the service constructor just like we do it in controller? Like..

$this->load->library('my_library');

OR is there any way to get CI instance in the service constructor like..

$CI = &get;_instance();

and then load the libraries manually,

Or do we need to autoload all libraries ..?  long face

function service ()
{
     parent
::Users();
     
$this->methodTable = array(    
     
'getUserDetails' => array( 'description' => 'Desc Here', 'access' => 'remote'),
     
'insertUser' => array( 'description' => 'Desc Here', 'access' => 'remote')
     );
}


Due to this I went for LoadVars, sendAndLoad etc.. to directly communicate with the controller. At the same time I miss the good features of amfphp.

Thank you for the reply. smile

Profile
 
 
Posted: 05 October 2008 11:07 PM   [ Ignore ]   [ # 19 ]  
Grad Student
Avatar
Rank
Total Posts:  38
Joined  08-29-2007

So how do the pathes stay correct. Let me elaborate.

So I have my amfphp structure:

siteroot/amfphp/services/MyClass.php

My CI structure:

siteroot/system/application/

I added the three files:

siteroot/ci_model_remote_close.php
siteroot
/ci_model_remote_open.php
siteroot
/config_constants.php

then in my remoting class, I include the files as described above:

require_once('../../ci_model_remote_open.php');
require_once(
APPPATH."/models/Sections.php");

But that returns me errors. Errors that make sense. Because essentially the pathes get thrown out of whack.The pathes set in constants seem to be relative rather then absolute.

so obviously this dynamically created include one does not work. The remoting class tries to find the Common.php of codeiginiter like so:

siteroot/amfphp/services/system/codeigniter/Common.php

so my question, how do I configure this correctly for my AMFPHP service to find its way to the data supplying model I created in my CI application.

I also tried setting the pathe to application and system folder as abosoulute, but it seems that the string given is not recognized as a path, so CI just doubles up the faulty path…

thanks

V

 Signature 

vevmedia code-igniter things

Profile
 
 
Posted: 13 February 2009 10:14 PM   [ Ignore ]   [ # 20 ]  
Summer Student
Total Posts:  1
Joined  02-13-2009

A simple way to call the CI Models for use with a service (AMFPHP / XMLRPC etc)
PHP 5 / CodeIgniter 1.7.1

/**
* Returns an instance of a CodeIgniter Model Class
* Note: if a default/correct controller is not set by the application
* then CI automagically returns a page not found instead
* @return object
*/
function spark($model_name)
{
    
static $instances;
    
$class_name = explode('/', $model_name);
    
$class_name = end($class_name);

    if(!
class_exists($class_name) || !isset($instances[$model_name])) {

        
// Load the global functions
        
require_once BASEPATH . 'codeigniter/Common' . EXT;

        
// Load the system constants
        
require_once APPPATH . 'config/constants' . EXT;

        
// Load CI base class for PHP5
        
require_once BASEPATH . 'codeigniter/Base5' . EXT;

        
// Instantiate the Controller
        
$CI = load_class('Controller');

        
// Load parent Model class
        
require_once BASEPATH . 'libraries/Model' . EXT;

        
$path = APPPATH . '/models/' . $model_name . EXT;
        require_once
$path;

        
// Store the instance
        
$instances[$model_name] = new $class_name();

    
}

    $class
= & $instances[$model_name];

    return
$class;
}
Profile
 
 
Posted: 15 February 2009 12:20 AM   [ Ignore ]   [ # 21 ]  
Grad Student
Avatar
Rank
Total Posts:  38
Joined  08-29-2007
Warning: Application::spark(BASEPATHcodeigniter/CommonEXT):
failed to open stream: Operation not permitted in
/amfphp/services/shantiamf/Application.php on line 47

the folder /amfphp/ is in the same dir as /system/

Looks like I am having something not in the proper Directory… CI is running alone, so is AMFPHP it is when I want them to talk to each other that this happens. Any help?

I am calling spark like so:

$this->spark('MyModel');

thank you

 Signature 

vevmedia code-igniter things

Profile
 
 
Posted: 17 March 2009 05:29 PM   [ Ignore ]   [ # 22 ]  
Grad Student
Avatar
Rank
Total Posts:  65
Joined  04-13-2007

I know this is an old thread, but wanted to drop a note, that we built an AMFPHP CI Library, tested and working, easy plug/play drop in and works.
http://codeigniter.com/wiki/AMF_Codeigniter_Library_No_Zend_No_Hooks_Etc./

 Signature 

twitter
philpalmieri.com

Profile
 
 
Posted: 13 January 2010 05:07 PM   [ Ignore ]   [ # 23 ]  
Summer Student
Avatar
Total Posts:  9
Joined  12-14-2009

I almost got it working. Im just stucked on this message “A Database Error Occurred

Error Number: 1046

No database selected”

Even trying to load the database in constructor model or in autoload in config…. the same problem ...
i will go deep it tomorrowz…

 Signature 

Tetranet website

Profile
 
 
Posted: 13 January 2010 05:42 PM   [ Ignore ]   [ # 24 ]  
Summer Student
Avatar
Total Posts:  9
Joined  12-14-2009

got working smoothly it was just some problems with the path = ).

 Signature 

Tetranet website

Profile
 
 
   
2 of 2
2
 
‹‹ question input to db      CSS, Images..... ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120618 Total Logged-in Users: 65
Total Topics: 126651 Total Anonymous Users: 2
Total Replies: 665790 Total Guests: 536
Total Posts: 792441    
Members ( View Memberlist )