/**
  * @ignore
  * @internal
  */
 protected function _query()
 {
     if ($this->_rs) {
         return;
     }
     $sql = $this->_filter['sql'];
     // get the first two words out of the query
     list($w1, $w2, $junk) = explode(' ', $sql);
     if (strtoupper($w1) == 'SELECT') {
         if (strtoupper($w2) != 'SQL_CALC_FOUND_ROWS') {
             // inject SQL_CALC_FOUND_ROWS
             $sql = substr_replace($sql, 'SELECT SQl_CALC_FOUND_ROWS', 0, strlen('SELECT'));
         }
     }
     $db = \cge_utils::get_db();
     $this->_rs = $db->SelectLimit($sql, $this->_filter['limit'], $this->_filter['offset'], $this->_filter['parms']);
     $this->_totalmatching = (int) $db->GetOne('SELECT FOUND_ROWS()');
 }
 public static function smarty_function_cge_country_options($params, $smarty)
 {
     $db = \cge_utils::get_db();
     $obj = \cge_utils::get_module(MOD_CGEXTENSIONS);
     $query = 'SELECT * FROM ' . CGEXTENSIONS_TABLE_COUNTRIES . ' ORDER BY sorting ASC,name ASC';
     $tmp = $db->GetAll($query);
     $output = '';
     if (isset($params['selectone'])) {
         $output .= '<option value="">' . trim($params['selectone']) . "</option>\n";
     }
     foreach ($tmp as $row) {
         $output .= "<option value=\"{$row['code']}\"";
         if (isset($params['selected']) && $params['selected'] == $row['code']) {
             $output .= ' selected="selected"';
         }
         $output .= ">{$row['name']}</option>\n";
     }
     return $output;
 }
示例#3
0
# in any Non GPL version of CMS Made simple, or in any version of CMS
# Made simple that does not indicate clearly and obviously in its admin
# section that the site was built with CMS Made simple.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Or read it online: http://www.gnu.org/licenses/licenses.html#GPL
#
#-------------------------------------------------------------------------
#END_LICENSE
$db = cge_utils::get_db();
$taboptarray = array('mysql' => 'TYPE=MyISAM');
$dict = NewDataDictionary($db);
$this->DeleteTemplate();
$this->RemovePreference();
$tmp = $dict->DropTableSQL(CGEXTENSIONS_TABLE_COUNTRIES);
$dict->ExecuteSQLArray($tmp);
$tmp = $dict->DropTableSQL(CGEXTENSIONS_TABLE_STATES);
$dict->ExecuteSQLArray($tmp);
$tmp = $dict->DropTableSQL(CGEXTENSIONS_TABLE_ASSOCDATA);
$dict->ExecuteSQLArray($tmp);
\CGExtensions\jsloader\jsloader::unregister_by_module($this->GetName());
$this->RemoveEventHandler('Core', 'ContentPostRender');
#
# EOF
#
示例#4
0
 /**
  * convert the current object to a format suitable for saving in the database
  *
  * @return string
  */
 public function to_dbformat()
 {
     $db = cge_utils::get_db();
     return trim($db->DbTimeSTamp($this->_time), "'");
 }
 public static function load_all()
 {
     if (is_array(self::$_cache[static::table_name()])) {
         return self::$_cache[static::table_name()];
     }
     self::$_cache[static::table_name()] = array();
     $db = \cge_utils::get_db();
     $query = 'SELECT id,name,description,iorder FROM ' . static::table_name() . ' ORDER BY iorder';
     $rows = $db->GetArray($query);
     if (!is_array($rows)) {
         return;
     }
     $class = get_called_class();
     foreach ($rows as $row) {
         $obj = new $class();
         $obj->_data = $row;
         self::$_cache[static::table_name()][$obj->id] = $obj;
     }
     return self::$_cache[static::table_name()];
 }
 /**
  * List all of the data matching the specified keys.
  * The fiewer keys specified should result in more matches.
  *
  * @param string $key1
  * @param string $key2 - An optional additional key that is combined with key1
  * @param string $key3 - An optional additional key that is combined with key1 and key2
  * @return array
  */
 public function listall($key1, $key2 = null, $key3 = null)
 {
     $parms = array();
     $where[] = array();
     $where[] = 'key1 = ?';
     $parms[] = $key1;
     $query = 'SELECT key1,key2,key3,key4 FROM ' . CGEXTENSIONS_TABLE_ASSOCDATA;
     if (!empty($key2)) {
         $where[] = 'key2 = ?';
         $parms[] = $key2;
         if (!empty($key3)) {
             $where[] = 'key3 = ?';
             $parms[] = $key3;
         }
     }
     if (count($where)) {
         $query .= ' WHERE ' + implode(' AND ', $where);
     }
     $db = cge_utils::get_db();
     $data = $db->GetArray($query, $parms);
     if (!$data) {
         return;
     }
     return $data;
 }
 /**
  * Convert a timestamp to database format
  *
  * @param int $ts
  * @return string
  */
 public static function ts_to_dbformat($ts)
 {
     $db = cge_utils::get_db();
     return trim($db->DbTimeSTamp($ts), "'");
 }