dtjwov4984 2014-10-08 13:35
浏览 28

在codeigniter中使用phpcassandra

Hi I am new to cassandra database. I am trying to do a project in codeigniter with cassandra database. I have downloaded the phpcassandra files through below link https://github.com/mauritsl/php-cassandra.

When I am trying to autoload my casssandra.php in codeigniter I got Non-existent class: Cassandra error. Why I got this error and how to solve the issue?

  • 写回答

1条回答 默认 最新

  • douda5706 2014-10-08 14:22
    关注

    You will need to create a wrapper for it if you wish to use it as a library.

    I would suggest you take the composer route. You can check on packagist for a suitable library.

    If you use this particular library phpcassa this is how you would go about getting it to work in Codeigniter.

    composer.json

    {
        "require": {
            "php": ">=5.3.0",
            "thobbs/phpcassa": "1.1.0"
        }
    
    }
    

    index.php

    require "../composer/autoload.php";
    

    system/core/codeigniter.php

    // Where codeigniter starts to load the Main Controller
    // $cassandraDB will be in the GLOBAL scope, so you may want to write a wrapper
    
    $cassandraDB = new ConnectionPool('localhost');
    
    // Then right after this
    // if (class_exists('CI_DB') AND isset($CI->db))
    // {
    //      $CI->db->close();
    // }
    
    $cassandraDB->close();
    

    User Model

    implement it how you wish in your models

    public function __construct()
    {
        //YOU MAY NEED TO PASS $cassandraDB AS A DEPENDANCY!!
    
        $this->users = new ColumnFamily($cassandraDB, 'Standard1');
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题