Welcome Guest, Not a member yet? Register   Sign In
  view calling a model?
Posted by: El Forum - 07-24-2008, 02:10 AM - Replies (15)

[eluser]sanct_arvin[/eluser]
can i use my view to get values from my model?

i'm trying to get all amenities associated with a specific room_id;

Code:
$this->load->model('Room_Model','', TRUE);
$data['query'] = $this->Room_Model->getRoomswithDesc();;
$this->load->view('rooms/roomview.php', $data);

in my view
Code:
<?php
    if($query->num_rows() > 0):
    foreach ($query->result() as $row):
?>
    <tr>
    <td>&lt;?=$row->room_num?&gt;</td>
    <td>&lt;?=$row->roomtype?&gt;</td>
    <td>&lt;?=$row->capacity?&gt;</td>
    <td>&lt;?=$row->description?&gt;
        &lt;?php
            // using $row->room_id; how can i call [i]getAmenities [/i]from my model?
        ?&gt;
        &lt;!-- need to insert all amenities here by using insert_id--&gt;
    
    </td>
    </tr>
&lt;?endforeach;?&gt;
&lt;?endif;?&gt;

in my model
Code:
function getAmenities($room_id){        
    $query = $this->db->query("SELECT a.name FROM amenities a JOIN room_amenities ra ON a.id = amenity_id WHERE room_id = $room_id");
    return $query;
}

any tip how to do it?
or any tips how to do it better


  Strange IE behaviour
Posted by: El Forum - 07-24-2008, 01:41 AM - Replies (4)

[eluser]fusionblu[/eluser]
I have a page (pratically rendered in a controller) that renders differently on IE when accessed from a remote machine (apache on linux). The page renders perfectly fine when accessed from a test server (localhost-apache on windows).
The CSS style in question is given below.

Code:
.container {
    Margin:10px 0px 15px 10px;
    position:relative;    
    display:block;    
    WIDTH: 100%; HEIGHT: 50px;
}
Doctype -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

Any help is great help.


  Where Query
Posted by: El Forum - 07-24-2008, 01:32 AM - Replies (5)

[eluser]Yash[/eluser]
function ReadComments($UrlTitle)
{



$this->db->where(array('UrlTitle'=>$UrlTitle));
$query = $this->db->get('comments');
$posts = $query->row_array();
return $posts;

}

It return only one row.

I want all of the rows for where query.


  watermark, gif
Posted by: El Forum - 07-24-2008, 12:59 AM - Replies (5)

[eluser]recoilme[/eluser]
Hi.

When i add watermark(an image) on animated gif its convert gif in static(
How solve this problem? Its possible?

Thx


  How Can I Destroy User Data After Insertion ?
Posted by: El Forum - 07-24-2008, 12:00 AM - Replies (10)

[eluser]Zeeshan Rasool[/eluser]
Hi all, here is a problem im facing.

Problem is , when i create a new user and click submit button the CREATE_USER_DB function executes and new user has been inserted. But when i refresh the page by pressing F5 or else an other user data is inserted in DB with same record values
How can i destroy userdata or $_POST data so it can be stopped?

Very Thnx in Advance.


  A way to have a variable sent to all views?
Posted by: El Forum - 07-23-2008, 11:25 PM - Replies (2)

[eluser]internut[/eluser]
Is there a way I can create a library to load something into a $data array if i'm always using:

Code:
$this->load->view('users_view',$data);

or

Code:
$this->load->view('something_else',$data);

?
IE: wanting to show a config or variable set once in all views?


  Load a Model within a Model
Posted by: El Forum - 07-23-2008, 11:15 PM - Replies (1)

[eluser]Unknown[/eluser]
Is it possible to load a model within a model?

For example, I have two models (Contact and Contact_Meta) and a controller (Admin).

Any help is appreciated.

Within Admin.php:

Code:
...
$this->load->model('contact');
$this->contact->delete_contact($contact_id);
...

Within Contact.php

Code:
...
function delete_contact ($contact_id)
{
  $this->load->model('contact_meta');
  $this->contact_meta->delete($contact_id); // fails here with the message: Undefined property: Contact::$contact_meta

  $this->db->where('contact_id',$contact_id);
  $this->db->delete('contact');
}
...

Within Contact_Meta.php

Code:
...
function delete_contact_meta ($contact_id)
{
  $this->db->where('contact_id',$contact_id);
  $this->db->delete('contact_meta');
}
...


  Calling a model function from within a plugin
Posted by: El Forum - 07-23-2008, 10:06 PM - Replies (3)

[eluser]Bob Sawyer[/eluser]
Sorry if this has been posted elsewhere; I searched for several different variations of the title and couldn't find anything. Anyway...

I am creating a fairly specialized CMS for a vertical market, and want to make it extensible with plugins. Instead of creating a whole separate plugin scheme, I am dropping all of the CMS plugins into a subfolder of the CI plugins directory.

By and large, these plugins will be fairly simple, however, at least one needs to access the database. Since plugins are not object-oriented, $this->db->whatever does not work. I'm already auto-loading the model, so simply including it the old fashioned way creates a second instance of the model class.

So, I'm a little bit lost here. Is it possible to call a model from within a plugin, and if so, what's the correct syntax?

Thanks,
Bob


  HTTP/HTTPS, without index.php, using htaccess, plus XHR
Posted by: El Forum - 07-23-2008, 09:42 PM - Replies (17)

[eluser]Phil_B[/eluser]
Removing index.php and forcing HTTP/HTTPS

I have read many posts about people trying to force HTTPS for some views and returning to HTTP for others. I struggled with this for a while too but I think this solution is pretty solid.

First of all, having your base_url automatically adjust between http and https makes everything much easier. This way all your base_url() and site_url() calls have the proper protocol.

Code:
$config['base_url'] = "http".((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "")."://".$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

Starting with the usual htaccess file:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    Options +FollowSymLinks
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

You can then check whether HTTPS is on or not with:

Code:
RewriteCond %{HTTPS} off
RewriteCond %{HTTPS} on

For example, to force HTTPS on all pages you could use the following:

Code:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]

To force HTTPS on some pages:

Code:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (auth|register|secure)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]

To return back to HTTP:

Code:
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301]

To return back to HTTP on all other pages, you need to add exceptions for the pages that are secure:

Code:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (auth|register|secure)
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(auth|register|secure)
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301]

To avoid a partially encrypted page, you need to add exceptions for any other URIs you might use such as your images or scripts folder. I like to place everything in a folder called 'static' ('static/images', 'static/js', etc) so I only add one exception for that.

Code:
RewriteCond %{REQUEST_URI} !(static|auth|register|secure)

The finished product:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    Options +FollowSymLinks
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1

    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} (auth|register|secure)
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301]

    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} !(static|auth|register|secure)
    RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>


HTTPS and XmlHttpRequests (Ajax)

Not only do XHR calls throw security errors when you try to load content between domains but also between HTTP and HTTPS. Secondly, the headers passed by apache allow browsers to automatically redirect but the XmlHttpRequest object does not.

To solve this you would have to add an exception for any URI that you planned on accessing from one protocol to another.

Example:

Code:
RewriteCond %{REQUEST_URI} !(static|auth|register|secure|categories/get_list|products/get_types)

&lt;?=site_url('categories/get_list');?&gt;

I quickly found out that this became tedious and confusing when I had a lot of requests in a secure environment. Routes to the rescue!

By adding the following to your routes file:

Code:
$route['xhr/(:any)'] = '$1';

And adding ‘xhr’ to your list of exceptions; you can now call any URI within your application without changing protocols while still allowing the browser to view that controller using another protocol.

Code:
RewriteCond %{REQUEST_URI} !(static|xhr|auth|register|secure)

&lt;?=site_url('xhr/categories/get_list');?&gt;

I hope this has been helpful!

Phil


  How add links, anchors, etc,. to the HTML Table Class?
Posted by: El Forum - 07-23-2008, 09:18 PM - Replies (5)

[eluser]Asinox[/eluser]
Hi, the HTML Table Class i think is wonderful, but, i want to ask, how ill add links , anchors, etc., to the data from html table class?

thanks u


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Getting supportedLocales ...
by InsiteFX
7 minutes ago
Type error in SYSTEMPATH\...
by kenjis
6 hours ago
composer didn't update to...
by Sarog
8 hours ago
Pipe on url modified in %
by kenjis
9 hours ago
Best way to create micros...
by kenjis
9 hours ago
How to use Codeigniter wi...
by kenjis
9 hours ago
extend url_to helper
by kenjis
9 hours ago
Limiting Stack Trace Erro...
by byrallier
Yesterday, 05:43 AM
External script access to...
by ezydev
04-21-2024, 11:41 PM
v4.5.1 Bug Fix Released
by kenjis
04-21-2024, 04:59 PM

Forum Statistics
» Members: 84,969
» Latest member: Wiculty
» Forum threads: 77,570
» Forum posts: 375,943

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB