-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsphinx_app_model.php
More file actions
79 lines (69 loc) · 1.67 KB
/
Copy pathsphinx_app_model.php
File metadata and controls
79 lines (69 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Sphinx App Model File
*
* Copyright (c) 2011 Anthony Putignano
*
* Distributed under the terms of the MIT License.
* Redistributions of files must retain the above copyright notice.
*
* PHP version 5.3
* CakePHP version 1.3
*
* @package sphinx
* @subpackage sphinx.models
* @copyright 2011 Anthony Putignano <contact@anthonyputignano.com>
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @link http://github.com/anthonyp/CakePHP-Sphinx-Plugin
*/
/**
* Sphinx App Model Class
*
* @package sphinx
* @subpackage sphinx.models
*/
class SphinxAppModel extends AppModel {
/**
* @var bool
*/
public $useTable = false;
/**
* Name of datasource config to use
*
* @var string
*/
public $useDbConfig = 'sphinx';
/**
* Adds the datasource to the connection manager if it's not already there,
* which it won't be if you've not added it to your app/config/database.php
* file.
*
* @author Anthony Putignano <contact@anthonyputignano.com>
* @since 0.1
* @param $id
* @param $table
* @param $ds
* @return void
*/
public function __construct ($id = false, $table = null, $ds = null) {
// Making sure the datasource is always set to 'sphinx', no matter what
if (!empty($id['ds'])) {
$id['ds'] = 'sphinx';
}
if (!empty($ds)) {
$ds = 'sphinx';
}
$sources = ConnectionManager::sourceList();
if (!in_array('sphinx', $sources)) {
ConnectionManager::create('sphinx', array(
'datasource' => 'Sphinx.SphinxSource',
'host' => 'localhost',
'port' => 9306,
'login' => null,
'password' => null
));
}
parent::__construct($id, $table, $ds);
}
}
?>