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 6042259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:46:13+00:00 2026-05-23T06:46:13+00:00

I am requiring two classes from the PHPCassa project into my class. Before I

  • 0

I am requiring two classes from the PHPCassa project into my class. Before I made my Class static I was able to call the method in selectColumnFamily. But now it does not work. Is there a way around this? Also is this the best strategy? I just want to be able to not have to re-connect to the Cassandra DB every time. So if I use CASSANDRA:: will it only connect once or multiple times?

Thanks in advance for any help.

class CASSANDRA {

    protected static $config = array();
    protected static $keyspace = NULL;
    protected static $servers = array();
    public static $pool = NULL;

    public function __construct()
    {

        require_once ('phpcassa/connection.php');
        require_once ('phpcassa/columnfamily.php');

        // Test the config group name
        $config = Kohana::config('cassandra');

        self::$servers = $config['servers'];
        self::$keyspace = $config['keyspace'];

        self::$pool = new ConnectionPool($this->keyspace, $this->servers);

    }

    public static function selectColumnFamily($column_family_name)
    {

        return new ColumnFamily(self::$pool, $column_family_name);

    }

}
  • 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-05-23T06:46:13+00:00Added an answer on May 23, 2026 at 6:46 am

    Ok first you are using $this to access static variables, this is wrong:

    self::$pool = new ConnectionPool($this->keyspace, $this->servers);
    

    You should use self:: instead of $this->.

    But the main problem is: the constructor is not called when using the static methods of a class! (well, unless you did a new CASSANDRA() just before, but that makes no sense to do that).

    Here, you setup the connection in the constructor, but if you don’t call it, then selectColumnFamily will fail because it will try to use a connection not set.

    A quick way to fix that is to rename the __construct() method to static init(), and do that when using the class:

    CASSANDRA::init();
    $foo = CASSANDRA::selectColumnFamily(...);
    

    But I highly encourage you to read a good tutorial and use OOP correctly, using objects and not static classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm tired of adding ten link libraries into my project, or requiring eight of
We have a number of embedded systems requiring r/w access to the filesystem which
How do you reverse a string in C or C++ without requiring a separate
I have a web service that is protected by requiring the consuming third party
I have a webservice (asmx file) in a directory requiring form authentication When I
Can I safely download and install .Net framework 3.5 SP1 without requiring my customers
This is a frequently recurring problem of generating a tree from a flat list
Suppose I have a non-recurring event that needs to be raised X seconds from
I have a horizontal site with 8 sections all requiring a full background image
Is there any way to do a cross site AJAX request without requiring JSONP?

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.