<?php $d = array(); Cloudmanic\Database\DB::set_select('DISTINCT ' . $field['LookAhead_Column']); foreach (Cloudmanic\Database\DB::set_table($field['LookAhead_Table'])->get() as $key2 => $row2) { if (!empty($row2[$field['LookAhead_Column']])) { $d[] = $row2[$field['LookAhead_Column']]; } } $array = json_encode($d); ?> <input type="text" data-provide="typeahead" name="<?php echo $row->name; ?> " value="<?php echo set_value($row->name, element($row->name, $data, '')); ?> " data-source='<?php echo $array; ?> ' />
public static function load_configuration_from_export($file) { // Make sure the file if valid. if (!is_file($file)) { return false; } $config = (require $file); $config = json_decode($config, TRUE); // Load database. self::setup_database(); // Make sure the database is built first. if (!self::is_table('CMS_Buckets')) { return false; } // Get the current state of the export. if ($stmt = Cloudmanic\Database\DB::query("SELECT * FROM CMS_State WHERE CMS_StateName = 'import-hash'")) { $entry = $stmt->fetch(PDO::FETCH_ASSOC); } else { $entry = false; } // Match the config state up with the current state to see if we have to do anything. if ($entry) { if ($config['hash'] == $entry['CMS_StateValue']) { return false; } } else { // Build the state entry. $q = array('CMS_StateName' => 'import-hash', 'CMS_StateValue' => '', 'CMS_StateUpdatedAt' => date('Y-m-d G:i:s'), 'CMS_StateCreatedAt' => date('Y-m-d G:i:s')); Cloudmanic\Database\DB::set_table('CMS_State')->insert($q); } // Loop through the data, delete the old data and insert the new. foreach ($config['tables'] as $key => $row) { Cloudmanic\Database\DB::query("TRUNCATE TABLE {$key}"); foreach ($row as $key2 => $row2) { Cloudmanic\Database\DB::set_table($key)->insert($row2); } } // Update the hash in the state table. $q = Cloudmanic\Database\DB::get_connection()->prepare("UPDATE CMS_State SET CMS_StateValue=? WHERE CMS_StateName = 'import-hash'"); $q->execute(array($config['hash'])); return true; }
<?php ini_set('display_errors', 1); error_reporting(E_ALL); require 'vendor/autoload.php'; // Static version Cloudmanic\Database\DB::connection('HOSTNAME HERE', 'USERNAME HERE', 'PASS HERE', 'DATABASE HERE'); Cloudmanic\Database\DB::set_table('Users'); $query = array('UsersFirstName' => 'Lady', 'UsersLastName' => 'Gaga'); $id = Cloudmanic\Database\DB::insert($query); echo '<pre>' . print_r($id, TRUE) . '</pre>'; // Instance version $db = new Cloudmanic\Database\Instance('HOSTNAME HERE', 'USERNAME HERE', 'PASS HERE', 'DATABASE HERE'); $db->set_table('Users'); $query = array('UsersFirstName' => 'Katie', 'UsersLastName' => 'Perry'); $id = $db->insert($query); echo '<pre>' . print_r($id, TRUE) . '</pre>';