3 /* +-----------------------------------------------------------------------------+
4 * Copyright 2016 matrix israel
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 3
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see
15 * http://www.gnu.org/licenses/licenses.html#GPL
16 * @author Oshri Rozmarin <oshri.rozmarin@gmail.com>
17 * +------------------------------------------------------------------------------+
21 namespace Multipledb\Model
;
22 use Zend\Db\Sql\Expression
;
23 use Zend\Db\TableGateway\TableGateway
;
24 use Zend\Db\Sql\Predicate
;
25 use \Application\Model\ApplicationTable
;
26 use Zend\Db\Adapter\Adapter
;
30 protected $tableGateway;
35 * MultipledbTable constructor.
36 * @param TableGateway $tableGateway
38 public function __construct(TableGateway
$tableGateway)
40 $this->tableGateway
= $tableGateway;
41 $adapter = \Zend\Db\TableGateway\Feature\GlobalAdapterFeature
::getStaticAdapter();
42 $this->adapter
= $adapter;
45 public function fetchAll()
47 /* $resultSet = $this->tableGateway->select();
51 $rs = $this->tableGateway
->select();
53 $rsArray[] = get_object_vars($r);
60 public function storeMultipledb($id = 0,$db = array()){
63 $db['password'] = my_encrypt($db['password']);
65 unset($db['password']);
69 $this->tableGateway
->update($db, array('id' => $id));
71 $this->tableGateway
->insert($db);
76 public function deleteMultidbById($id){
77 $this->tableGateway
->delete(array('id' => (int)$id));
80 public function getMultipledbById($id){
82 $rowset = $this->tableGateway
->select(array('id' => $id));
83 $row = $rowset->current();
86 //throw new \Exception("Could not find row $serial_no");
93 public function randomSafeKey() {
94 $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$%&#@(){}[]<>~=?.*+-!';
95 $pass = array(); //remember to declare $pass as an array
96 $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
97 for ($i = 0; $i < 32; $i++
) {
98 $n = mt_rand(0, $alphaLength);
99 $pass[] = $alphabet[$n];
101 return implode($pass); //turn the array into a string