PHP Database, 0 Examples

PHP Database - 30 examples found. These are the top rated real world PHP examples of Database extracted from open source projects. You can rate examples to help us improve the quality of examples.
Author: Adam Clarke
Example #1
0
function ShowMenuFiche($p_dossier)
{
    $cn = new Database($p_dossier);
    $mod = "&ac=" . $_REQUEST['ac'];
    $str_dossier = dossier::get() . $mod;
    echo '<div class="lmenu">';
    echo '<TABLE>';
    echo '<TR><TD colspan="1" class="mtitle"  style="width:auto" >
    <A class="mtitle" HREF="?p_action=fiche&action=add_modele&fiche=modele&' . $str_dossier . '">' . _('Création') . '</A></TD>
    <TD><A class="mtitle" HREF="?p_action=fiche&' . $str_dossier . '">' . _('Recherche') . '</A></TD>
    </TR>';
    $Res = $cn->exec_sql("select fd_id,fd_label from fiche_def order by fd_label");
    $Max = Database::num_row($Res);
    for ($i = 0; $i < $Max; $i++) {
        $l_line = Database::fetch_array($Res, $i);
        printf('<TR><TD class="cell">
               <A class="mtitle" HREF="?p_action=fiche&action=modifier&fiche=%d&%s">%s</A></TD>
               <TD class="mshort">
               <A class="mtitle" HREF="?p_action=fiche&action=vue&fiche=%d&%s">Liste</A>
               </TD>
               </TR>', $l_line['fd_id'], $str_dossier, $l_line['fd_label'], $l_line['fd_id'], $str_dossier);
    }
    echo "</TABLE>";
    echo '</div>';
}
Example #2
0
 /**
  *
  */
 public function parse(Database $database)
 {
     $this->addVendorInfo = $this->getGeneratorConfig()->getBuildProperty('addVendorInfo');
     $stmt = $this->dbh->query("SHOW TABLES");
     // First load the tables (important that this happen before filling out details of tables)
     $tables = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $name = $row[0];
         $table = new Table($name);
         $database->addTable($table);
         $tables[] = $table;
     }
     // Now populate only columns.
     foreach ($tables as $table) {
         $this->addColumns($table);
     }
     // Now add indexes and constraints.
     foreach ($tables as $table) {
         $this->addForeignKeys($table);
         $this->addIndexes($table);
         $this->addPrimaryKey($table);
         if ($this->addVendorInfo) {
             $this->addTableVendorInfo($table);
         }
     }
 }
Example #3
0
 function __construct($Owner)
 {
     parent::__construct();
     $this->pack_start(new GtkLabel(latin1(' Tipo de Endereço: ')), false);
     $this->store = new GtkListStore(TYPE_STRING, TYPE_LONG);
     $this->pack_start($this->combobox = new GtkComboBox($this->store));
     $this->combobox->pack_start($cell = new GtkCellRendererText());
     $this->combobox->set_attributes($cell, 'text', 0);
     $this->combobox->connect('changed', array($this, 'tipo_endereco_changed'));
     $this->show_all();
     /*
      * preenche lista
      */
     $db = new Database($Owner, true);
     if (!$db->link) {
         return;
     }
     /*
      * Tipo de Endereco
      */
     if (!$db->multi_query('SELECT * FROM Vw_Tipos_Endereco')) {
         return;
     }
     $this->store->clear();
     unset($this->it);
     while ($line = $db->line()) {
         $row = $this->store->append();
         $this->store->set($row, 0, $line['Descricao'], 1, $line['Id']);
         $this->it[$line['Id']] = $row;
     }
 }
Example #4
0
 /**
  *
  */
 public function parse(Database $database, Task $task = null)
 {
     $stmt = $this->dbh->query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'");
     // First load the tables (important that this happen before filling out details of tables)
     $tables = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $name = $row[0];
         if ($name == $this->getMigrationTable()) {
             continue;
         }
         $table = new Table($name);
         $table->setIdMethod($database->getDefaultIdMethod());
         $database->addTable($table);
         $tables[] = $table;
     }
     // Now populate only columns.
     foreach ($tables as $table) {
         $this->addColumns($table);
     }
     // Now add indexes and constraints.
     foreach ($tables as $table) {
         $this->addForeignKeys($table);
         $this->addIndexes($table);
         $this->addPrimaryKey($table);
     }
     return count($tables);
 }
Example #5
0
 static function queue($params)
 {
     $db = new Database();
     # MailQueue class can be created
     $script = "INSERT INTO MailQueue SET `type` = :type,\n                    senderName = :senderName,\n                    senderEmail = :senderEmail,\n                    receiverName = :receiverName,\n                    receiverEmail = :receiverEmail,\n                    cc = :cc,\n                    bcc = :bcc,\n                    subject = :subject,\n                    body = :body";
     return $db->executeUpdate($script, $params);
 }
Example #6
0
function getEquip()
{
    $db = new Database();
    $link = $db->connect();
    $result = $db->select($link, 'equip_type');
    return $result;
}
Example #7
0
	/**
	 * Compile the SQL query and return it.
	 *
	 * @param   object  Database instance
	 * @return  string
	 */
	public function compile(Database $db)
	{
		// Start a deletion query
		$query = 'DELETE FROM '.$db->quote_table($this->_table);

		if ( ! empty($this->_where))
		{
			// Add deletion conditions
			$query .= ' WHERE '.$this->_compile_conditions($db, $this->_where);
		}

		if ( ! empty($this->_order_by))
		{
			// Add sorting
			$query .= ' '.$this->_compile_order_by($db, $this->_order_by);
		}

		if ($this->_limit !== NULL && substr($db->_db_type, 0, 6) !== 'sqlite')
		{
			// Add limiting
			$query .= ' LIMIT '.$this->_limit;
		}

		return $query;
	}
 function getDatosClteClave($clave)
 {
     $con = new Database();
     $query = "select * from clientes_todos where clave_agrupadora = {$clave} order by alta desc limit 1";
     $r = $con->Fetch($query);
     return $r;
 }
Example #9
0
 /**
  * Compile the SQL partial for a JOIN statement and return it.
  *
  * @param   object  Database instance
  * @return  string
  */
 public function compile(Database $db)
 {
     if ($this->_type) {
         $sql = strtoupper($this->_type) . ' JOIN';
     } else {
         $sql = 'JOIN';
     }
     // Quote the table name that is being joined
     $sql .= ' ' . $db->quote_table($this->_table);
     if (!empty($this->_using)) {
         // Quote and concat the columns
         $sql .= ' USING (' . implode(', ', array_map(array($db, 'quote_column'), $this->_using)) . ')';
     } else {
         $conditions = array();
         foreach ($this->_on as $condition) {
             // Split the condition
             list($c1, $op, $c2) = $condition;
             if ($op) {
                 // Make the operator uppercase and spaced
                 $op = ' ' . strtoupper($op);
             }
             // Quote each of the columns used for the condition
             $conditions[] = $db->quote_column($c1) . $op . ' ' . $db->quote_column($c2);
         }
         // Concat the conditions "... AND ..."
         $sql .= ' ON (' . implode(' AND ', $conditions) . ')';
     }
     return $sql;
 }
 function testSelect()
 {
     $db = new Database();
     $sql = "SELECT COUNT(*) AS count FROM members";
     $result = $db->select($sql);
     $this->assertTrue($result[0]["count"] === 0);
 }
Example #11
0
 function getBooksByIdUser($idUser, $idBook)
 {
     $db = new Database();
     $query = "SELECT * FROM books b LEFT JOIN users u  ON b.fk_owner = u.user_id WHERE b.id_book ='{$idBook}' AND b.fk_user='{$idUser}'";
     $arrayBooks = $db->select($query);
     return $this->arrayBooks = $arrayBooks;
 }
Example #12
0
 function __construct($Owner)
 {
     parent::__construct();
     $this->pack_start(new GtkLabel(' Fornecedor: '), false);
     $completion = new GtkEntryCompletion();
     $completion->set_model($this->store = new GtkListStore(TYPE_STRING, TYPE_LONG));
     $completion->set_text_column(0);
     $completion->pack_start($cell = new GtkCellRendererText());
     $completion->set_attributes($cell, 'text', 1);
     $completion->connect('match-selected', array($this, 'fornecedor_selected'));
     $this->pack_start($this->entry = new GtkEntry());
     $this->entry->set_completion($completion);
     $this->show_all();
     /*
      * preenche lista
      */
     $db = new Database($Owner, true);
     if (!$db->link) {
         return;
     }
     /*
      * Fornecedores
      */
     if (!$db->multi_query('SELECT * FROM Vw_Fornecedores')) {
         return;
     }
     $this->store->clear();
     unset($this->it);
     while ($line = $db->line()) {
         $row = $this->store->append();
         $this->store->set($row, 0, $line['Nome'], 1, $line['Id']);
         $this->it[$line['Id']] = $row;
     }
 }
Example #13
0
 function getAppointmentPatientList($patientName, $hosiptal, $appdate)
 {
     $dbConnection = new Database();
     $sql = "SELECT * from appointment where patientName LIKE :patientName and hosiptalid = :hosiptalid and appointementdate = :appdate and status = 'N'";
     //   echo $sql;
     //    echo $patientName;
     try {
         $db = $dbConnection->getConnection();
         $stmt = $db->prepare($sql);
         $stmt->bindValue("patientName", "%" . $patientName . "%", PDO::PARAM_STR);
         $stmt->bindParam("hosiptalid", $hosiptal);
         $stmt->bindParam("appdate", $appdate);
         $stmt->execute();
         $appointmentDetails = $stmt->fetchAll(PDO::FETCH_OBJ);
         $db = null;
         //$_SESSION['userDetails'] = $userDetails;
         // echo $stmt->debugDumpParams();
         //  print_r($userDetails);
         return $appointmentDetails;
     } catch (PDOException $e) {
         echo '{"error":{"text":' . $e->getMessage() . '}}';
     } catch (Exception $e1) {
         echo '{"error11":{"text11":' . $e1->getMessage() . '}}';
     }
 }
Example #14
0
function main($post_data)
{
    $db = new Database();
    if (!$db->connect()) {
        exit_with_error('DatabaseConnectionFailure');
    }
    $report = json_decode($post_data, true);
    verify_slave($db, $report);
    $commits = array_get($report, 'commits', array());
    foreach ($commits as $commit_info) {
        if (!array_key_exists('repository', $commit_info)) {
            exit_with_error('MissingRepositoryName', array('commit' => $commit_info));
        }
        if (!array_key_exists('revision', $commit_info)) {
            exit_with_error('MissingRevision', array('commit' => $commit_info));
        }
        require_format('Revision', $commit_info['revision'], '/^[A-Za-z0-9 \\.]+$/');
        if (array_key_exists('author', $commit_info) && !is_array($commit_info['author'])) {
            exit_with_error('InvalidAuthorFormat', array('commit' => $commit_info));
        }
    }
    $db->begin_transaction();
    foreach ($commits as $commit_info) {
        $repository_id = $db->select_or_insert_row('repositories', 'repository', array('name' => $commit_info['repository']));
        if (!$repository_id) {
            $db->rollback_transaction();
            exit_with_error('FailedToInsertRepository', array('commit' => $commit_info));
        }
        $author = array_get($commit_info, 'author');
        $committer_id = NULL;
        if ($author) {
            $account = array_get($author, 'account');
            $committer_query = array('repository' => $repository_id, 'account' => $account);
            $committer_data = $committer_query;
            $name = array_get($author, 'name');
            if ($name) {
                $committer_data['name'] = $name;
            }
            $committer_id = $db->update_or_insert_row('committers', 'committer', $committer_query, $committer_data);
            if (!$committer_id) {
                $db->rollback_transaction();
                exit_with_error('FailedToInsertCommitter', array('committer' => $committer_data));
            }
        }
        $parent_revision = array_get($commit_info, 'parent');
        $parent_id = NULL;
        if ($parent_revision) {
            $parent_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $parent_revision));
            if (!$parent_commit) {
                $db->rollback_transaction();
                exit_with_error('FailedToFindParentCommit', array('commit' => $commit_info));
            }
            $parent_id = $parent_commit['commit_id'];
        }
        $data = array('repository' => $repository_id, 'revision' => $commit_info['revision'], 'parent' => $parent_id, 'order' => array_get($commit_info, 'order'), 'time' => array_get($commit_info, 'time'), 'committer' => $committer_id, 'message' => array_get($commit_info, 'message'), 'reported' => true);
        $db->update_or_insert_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $data['revision']), $data);
    }
    $db->commit_transaction();
    exit_with_success();
}
Example #15
0
 /**
  * Function to support the services/data_cleaner/verify web-service. 
  * Receives a list of proposed records and applies verification rules to them, then
  * returns a list of verification notices.
  * Input is provided in the $_GET or $_POST data sent to the method as follows:
  * auth_token - read authorisation token
  * nonce - read nonce
  * sample - Provides details of the sample being verified. If verifying a list
  * of records from different places or dates then the sample entry can be ommitted or only partially
  * filled-in with the missing information provided on a record by record bases. A JSON formatted
  * object with entries for sample:survey_id, sample:date, sample:entered_sref and sample:entered_sref_system, plus 
  * optional sample:geom (WKT format).
  * occurrences - JSON format, provide an array of the occurrence record to verify. Each record is an object
  * with occurrence:taxa_taxon_list_id, an optional stage plus any of the values for the sample which need to be 
  * specified on a record by record bases. I.e. provide sample:date if the sample information sent
  * does not include a date, or a date is included but this record is for a different date.
  * rule_types - JSON formatted array of the rule types to run. If not provided, then all rule types are run.
  * E.g. ["WithoutPolygon","PeriodWithinYear"] to run just without polygon and period within year checks.
  * @return JSON A JSON array containing a list of notifications. Each notification is a JSON
  * object, with taxa_taxon_list_id and message properties.
  */
 public function verify()
 {
     // authenticate requesting website for this service
     $this->authenticate('read');
     if (isset($_REQUEST['sample'])) {
         $sample = json_decode($_REQUEST['sample'], true);
     }
     if (isset($_REQUEST['occurrences'])) {
         $occurrences = json_decode($_REQUEST['occurrences'], true);
     }
     if (empty($sample) || empty($occurrences)) {
         $this->response = 'Invalid parameters';
     } else {
         $db = new Database();
         // Create an empty template table
         $db->query("select * into temporary occdelta from cache_occurrences limit 0;");
         try {
             $this->prepareOccdelta($db, $sample, $occurrences);
             $r = $this->runRules($db);
             $db->query('drop table occdelta');
             $this->content_type = 'Content-Type: application/json';
             $this->response = json_encode($r);
         } catch (Exception $e) {
             $db->query('drop table occdelta');
             $this->response = "Query failed";
             error::log_error('Error occurred calling verification rule service', $e);
         }
     }
     $this->send_response();
 }
Example #16
0
 public function setSession()
 {
     session_start();
     $page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : '';
     if ($page_mode == 'login') {
         $this->password = sha1($_POST['password']);
         $this->userName = $_POST['userName'];
         try {
             $dbh = new Database();
             $data = array(':userName' => $this->userName, ':password' => $this->password);
             $sql = "SELECT * FROM {$this->tableName} WHERE user_name=:userName AND password = :password";
             $sth = $dbh->prepare($sql);
             $sth->execute($data);
             $sth->setFetchMode(PDO::FETCH_ASSOC);
             $row = $sth->fetch();
         } catch (PDOException $e) {
             echo "I'm sorry, Dave. I'm afraid I can't do that.";
             file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
             echo $e->getMessage();
         }
         if (!$row) {
             $this->errorString = 'Clave o nombre de usuario incorrectos';
         } else {
             $_SESSION['userId'] = $row["{$this->tableId}"];
             $_SESSION['userName'] = $row['user_name'];
             header('Location: index.php');
         }
     }
 }
Example #17
0
	function delete()
	{
		$db = new Database();
		$sql = sprintf("delete from order_props where id = %d", $this->id);
		$db->executeSQL($sql, __FILE__, __LINE__, false);
		$db->close();
	}
Example #18
0
 /**
  * Compile the SQL query and return it.
  *
  * @param   object  Database instance
  * @return  string
  */
 public function compile(Database $db)
 {
     $query = 'ALTER TABLE ' . $db->quote_table($this->_table) . ' ';
     $lines = array();
     if ($this->_name !== NULL) {
         $lines[] = 'RENAME TO ' . $db->quote_table($this->_name) . '; ';
     }
     if (count($this->_add_columns) > 0) {
         $columns = array();
         $sql = $query . 'ADD(';
         foreach ($this->_add_columns as $name => $params) {
             $columns[] = Database_Query_Builder::compile_column($name, $params);
         }
         $sql .= implode($columns, ',') . '); ';
         $lines[] = $sql;
     }
     if (count($this->_modify_columns) > 0) {
         $columns = array();
         $sql = $query . 'MODIFY(';
         foreach ($this->_modify_columns as $name => $params) {
             $columns[] = Database_Query_Builder::compile_column($name, $params);
         }
         $sql .= implode($columns, ',') . '); ';
         $lines[] = $sql;
     }
     if (count($this->_drop_columns) > 0) {
         foreach ($this->_drop_columns as $name) {
             $drop = new Database_Query_Builder_Drop('column', $name);
             $lines[] = $drop->compile() . ';';
         }
     }
 }
 /**
  * Tests the get_custom_forms method
  *
  * @test
  */
 public function testGetCustomForms()
 {
     // Database instance for the test
     $db = new Database();
     // The record count should be the same since get_custom_forms() has no predicates
     $this->assertEquals($db->count_records('form'), customforms::get_custom_forms()->count());
 }
Example #20
0
 public static function validate($connection)
 {
     if (isset($_COOKIE['authenticated'])) {
         $userData = explode('##', $_COOKIE['authenticated']);
         $email = $userData[0];
         $saltedEmail = $userData[1];
         $db = new Database($connection);
         $userData = $db->query('SELECT * 
								FROM users 
								WHERE email = :email', array(':email' => $email));
         if (isset($userData['data'][0])) {
             $salt = $userData['data'][0]['salt'];
             $newlySaltedEmail = hash('sha512', $salt . $email);
             if ($newlySaltedEmail == $saltedEmail) {
                 # Cookie is correct
                 return true;
             } else {
                 # Password niet correct
                 return false;
             }
         } else {
             # User niet gevonden
             return false;
         }
     } else {
         #Cookie niet geset
         return false;
     }
 }
Example #21
0
 function getUdi()
 {
     $con = new Database();
     $sql = "select  u.valor , max(u.fecha_captura) from valor_udi as u limit 1";
     $con->Query($sql);
     return $con;
 }
 /**
  * Gets a single status
  *
  * @return array
  */
 public function getNextID()
 {
     $db = new Database();
     $status = $db->query('SELECT id FROM orders_statuses ORDER BY id DESC');
     $next = $status[0]->id + 1;
     return $next;
 }
Example #23
0
 public function deletePost()
 {
     $database = new Database();
     $id = (int) $this->id;
     $dml = sprintf("delete from post where id = %d limit 1", $id);
     return $database->executeDml($dml);
 }
 public function cargarMenu($idUsuario)
 {
     $query = "Select md.nombre, md.ruta, m.nombre as menu, m.idMenu from tblusuariopermisos as up join \n                tblmenudetalle as md on up.idPermiso = md.idMenuDetalle\n                join tblmenu as m on m.idMenu = md.idMenu\n                WHERE up.idUsuario = {$idUsuario}\n                order by m.idMenu, md.orden";
     $con = new Database();
     $con->Query($query);
     return $con;
 }
Example #25
0
 /**
  * Save layer relations.
  *
  * @param mixed          $layerId       The layer id values.
  * @param \DataContainer $dataContainer The dataContainer driver.
  *
  * @return null
  */
 public function saveLayerRelations($layerId, $dataContainer)
 {
     $new = deserialize($layerId, true);
     $values = array();
     $result = $this->database->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=? order BY sorting')->execute($dataContainer->id);
     while ($result->next()) {
         $values[$result->lid] = $result->row();
     }
     $sorting = 0;
     foreach ($new as $layerId) {
         if (!isset($values[$layerId])) {
             $this->database->prepare('INSERT INTO tl_leaflet_map_layer %s')->set(array('tstamp' => time(), 'lid' => $layerId, 'mid' => $dataContainer->id, 'sorting' => $sorting))->execute();
             $sorting += 128;
         } else {
             if ($values[$layerId]['sorting'] <= $sorting - 128 || $values[$layerId]['sorting'] >= $sorting + 128) {
                 $this->database->prepare('UPDATE tl_leaflet_map_layer %s WHERE id=?')->set(array('tstamp' => time(), 'sorting' => $sorting))->execute($values[$layerId]['id']);
             }
             $sorting += 128;
             unset($values[$layerId]);
         }
     }
     $ids = array_map(function ($item) {
         return $item['id'];
     }, $values);
     if ($ids) {
         $this->database->query('DELETE FROM tl_leaflet_map_layer WHERE id IN(' . implode(',', $ids) . ')');
     }
     return null;
 }
 private function updateEvent($user_id, $user_password, $event_id, $desc)
 {
     $response = array();
     $response["success"] = 0;
     $jsonView = new JsonViewer();
     $tryLogin = new TryUserLogin($user_id, $user_password);
     if ($tryLogin->isExists()) {
         //update the events
         $database = new Database();
         $sql = "UPDATE " . EventTable::TableName . " set " . EventTable::Description . "=:desc WHERE " . EventTable::Id . "=:id";
         $smt = $database->prepare($sql);
         $smt->bindValue(":id", $event_id);
         $smt->bindValue(":desc", $desc);
         $status = $smt->execute();
         if ($status) {
             $response["success"] = 1;
             $response["message"] = "Description updated";
         } else {
             $response["error_message"] = "No event with such information found";
         }
     } else {
         $response["error_message"] = "Invalid user login details";
     }
     $jsonView->setContent($response);
     return $jsonView;
 }
 /**
  * Create the DOT syntax for a given databases.
  *
  * @param $database Database
  *
  * @return string The DOT syntax created.
  */
 public static function create(Database $database)
 {
     $dotSyntax = '';
     // table nodes
     foreach ($database->getTables() as $table) {
         $columnsSyntax = '';
         foreach ($table->getColumns() as $column) {
             $attributes = '';
             if (count($column->getForeignKeys()) > 0) {
                 $attributes .= ' [FK]';
             }
             if ($column->isPrimaryKey()) {
                 $attributes .= ' [PK]';
             }
             $columnsSyntax .= sprintf('%s (%s)%s\\l', $column->getName(), $column->getType(), $attributes);
         }
         $nodeSyntax = sprintf('node%s [label="{<table>%s|<cols>%s}", shape=record];', $table->getName(), $table->getName(), $columnsSyntax);
         $dotSyntax .= "{$nodeSyntax}\n";
     }
     // relation nodes
     foreach ($database->getTables() as $table) {
         foreach ($table->getColumns() as $column) {
             foreach ($column->getForeignKeys() as $fk) {
                 $relationSyntax = sprintf('node%s:cols -> node%s:table [label="%s=%s"];', $table->getName(), $fk->getForeignTableName(), $column->getName(), implode(',', $fk->getForeignColumns()));
                 $dotSyntax .= "{$relationSyntax}\n";
             }
         }
     }
     return sprintf("digraph G {\n%s}\n", $dotSyntax);
 }
Example #28
0
 public function index()
 {
     $this->template->title = 'Cart';
     $this->template->metaDescription = '';
     $this->template->content = View::factory('cart')->bind('p', $this->cart);
     $this->cart = $this->session->get('Basket');
     $cart = new Basket();
     $this->additionalInfo = array();
     if ($cart->size() > 0) {
         $products = array();
         foreach ($cart->items() as $index => $item) {
             $products[] = $item->id;
         }
         $db = new Database();
         $rows = $db->query('SELECT d.description FROM discounts d JOIN discounts_objects AS do ON (do.discount_id=d.id) WHERE d.effective_from <= now() AND d.effective_to >= now() AND d.type_id=1 AND do.object_id IN (' . join(',', $products) . ')');
         foreach ($rows as $row) {
             $this->additionalInfo[] = $row->description;
         }
     }
     if (isset($_POST['update'])) {
         foreach ($cart->items() as $index => $item) {
             //update quntities
             if ($item->qty != $_POST['quantity'][$index]) {
                 $item->qty = $_POST['quantity'][$index];
                 $cart->update($item);
             }
             //delete products
             if (isset($_POST['delete'][$index]) and $_POST['delete'][$index] == 'on') {
                 $item->qty = 0;
                 $cart->update($item);
             }
         }
         $this->cart = $this->session->get('Basket');
     }
 }
Example #29
0
 public function getOrganizacion()
 {
     $coneccion = new Database();
     $id = $_SESSION['usuario']['id'];
     $obj = $coneccion->query("SELECT usu.*,IFNULL(nombre, '') AS nombre, IFNULL(calle, '') AS calle, IFNULL(numero, 0) AS numero, IFNULL(colonia, 0) AS colonia,\n                    IFNULL(codigo_postal, 0) AS codigo_postal, IFNULL(ciudad, '') AS ciudad, IFNULL(pais,'') AS pais, IFNULL(telefono, '') AS telefono,\n                    IFNULL(descripcion, '') AS descripcion, IFNULL(estado, '') AS estado\n                    FROM usuario usu\n                    LEFT JOIN organizacion org ON org.id_usuario = usu.id\n                    WHERE usu.id={$id}");
     $result = $obj->fetch_object();
     if (is_object($result)) {
         return $result;
     } else {
         $temp = new stdClass();
         $temp->nombre = "";
         $temp->descripcion = "";
         $temp->calle = "";
         $temp->numero = "";
         $temp->colonia = "";
         $temp->codigo_postal = "";
         $temp->ciudad = "";
         $temp->pais = "";
         $temp->telefono = "";
         $temp->estado = "";
         $temp->correo_electronico = "";
         $temp->contrasena = "";
         return $temp;
     }
 }
Example #30
0
  public function createLoginByIp($ip, $customerId = null, $status = 0)
  {
      $database = new Database();
      return $database->executeSql('
	INSERT INTO Login (LoginIp, LoginTime, Customer_Id, status)
	VALUES (?,NOW(),?,?)', [$ip, $customerId, $status]);
  }