Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:09:59+00:00 2026-06-01T16:09:59+00:00

I am using Kohana MVC framework. I want to add a module that will

  • 0

I am using Kohana MVC framework. I want to add a module that will work with PHPCassa object (Cassandra NoSQL).

Problem is that when I create the object I have all it’s properties and I can interact with it in construct, but when I create it from different place it’s returning as empty object.

I’m sure that I am missing something since I’m relatevely new to OOP. Please help me out here.

Module file

<?php

// Loading cassandra libraries, tried to load them here, did not help
//require 'application/modules/cassandra/lib/connection.php';
//require 'application/modules/cassandra/lib/columnfamily.php';

class Cassandra {

    function __construct($columnFamily) {
        // Loading cassandra libraries
        require 'application/modules/cassandra/lib/connection.php';
        require 'application/modules/cassandra/lib/columnfamily.php';

        $pool = new ConnectionPool('localhost');
        $cf = new ColumnFamily($pool, $columnFamily);

        // print_r($cf); // This will print object with all the proporties that I can use

        return $cf;
    }

Class that will load the module and will create empty object

<?php

class Controller_Main extends Controller {

    public function action_index() {
        $a = new Cassandra('timeline');
        echo '<pre>';
        print_r($a); // This will print out empty Cassandra object
        die();

        //$this->response->body('hello, world!');
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:10:00+00:00Added an answer on June 1, 2026 at 4:10 pm

    Doing it wrong way , you are creating two object in constructor , one the Cassandra object and the other is ColumnFamily and obviously the new Cassandra('timeline'); will return the Cassandra object.

    Try this way :

    class Cassandra {
    
        static function LoadCassandra($columnFamily) {
            // Loading cassandra libraries
            require 'application/modules/cassandra/lib/connection.php';
            require 'application/modules/cassandra/lib/columnfamily.php';
    
            $pool = new ConnectionPool('localhost');
            $cf = new ColumnFamily($pool, $columnFamily);
    
            return $cf;
        }
    

    And use it :

    class Controller_Main extends Controller {
    
        public function action_index() {
            $a =  Cassandra::LoadCassandra('timeline');
            echo '<pre>';
            print_r($a); // This will print out empty Cassandra object
            die();
    
            //$this->response->body('hello, world!');
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a couple of MVC sites using Kohana as my framework. Each
I'm busy building an MVC application in PHP using Kohana MVC framework, and it
I am using an objected oriented MVC framework in PHP (Kohana) and have kind
I am using the Kohana framework (but I think it's irrelevant for this question)
I'm investigating using Kohana for my next project. The site will consist of user
I'm using Kohana validation library and I want to set up my own user
Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I'm
I want to update a record in a table. I'm using Kohana 3.0 and
i have a form using kohana form helper. in a select field i want
I'm using Kohana framework for my project development, I need to introduce new rules

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.