Welcome Guest, Not a member yet? Register   Sign In
  calling controller functions
Posted by: El Forum - 06-04-2008, 12:34 AM - Replies (1)

[eluser]edhrx[/eluser]
hi,
Is this 'legitimate' code

I have a controller with these functions

function listall($clientid = "")

function save()

listall just just shows a list of stuff. If the $clientid is "" then it gets the clientid from a $this->input->post. The user eventually edits a record and saves the form which uses controllername/save. Works ok.

Is it acceptable (it works) to call the listall function from the save function passing in the clientid variable... should I be using a redirect



Ed.


  PHP Short Tags Not Working Anymore
Posted by: El Forum - 06-03-2008, 11:54 PM - No Replies

[eluser]Unknown[/eluser]
After upgrading to 1.6.2, PHP short tags are not working anymore when the following configurations are used.

From system/application/config/config.php:

Code:
$config['rewrite_short_tags'] = TRUE;

From php.ini:
Code:
short_open_tag = Off

These produce the error:
Code:
Parse error: syntax error, unexpected '<' in /home/waldemar/public_html/halalan/system/libraries/Loader.php(706) : eval()'d code on line 1

Line 706 in 1.6.1:
Code:
echo eval('?&gt;'.preg_replace("/;*\s*\?&gt;/", "; ?&gt;", str_replace('&lt;?=', '&lt;?php echo ', file_get_contents($_ci_path))).'&lt;?php ');

Line 706 in 1.6.2:
Code:
echo eval(preg_replace("/;*\s*\?&gt;/", "; ?&gt;", str_replace('&lt;?=', '&lt;?php echo ', file_get_contents($_ci_path))));

The configurations above are working in 1.6.1.


  Best Login script
Posted by: El Forum - 06-03-2008, 11:33 PM - Replies (11)

[eluser]stuffradio[/eluser]
Which is the best one? I want something basic that I can look at and easily develop to my needs. I would make my own but I don't really understand how to do that yet with CodeIgniter.

I've made several with sessions in a procedural method of writing PHP. So if there is an example of how people do it with Code Igniter I'd be able to make my own.


  Load class in outside directory in CI application path
Posted by: El Forum - 06-03-2008, 09:31 PM - Replies (4)

[eluser]Marcus Cavalcanti[/eluser]
Hi CI people!

I have an application structure like example below:

Code:
[root]
- css
- img
- js
- swf
- system
   - application
      - backend
         - config
         - controllers
         - errors
         - helpers
         - ... (more)
      - frontend
         - config
         - controllers
         - errors
         - helpers
         - ... (more)
      - models
      - services
         - test.php
   - cache
   - codeigniter
   - database
   - fonts
   - helpers
   - language
   - libraries
   - logs
   - plugins
   - scaffolding

The 'services' directory in application path has many classes to manage common business logic in my application domain, so i need to use this classes in my two applications: frontend and backend

The problem begins when i try to load any class, with this code:

Controller
Code:
&lt;?php

class Testing extends Controller {

    function Testing()    {
        parent::Controller();    
    }
    
    function index() {        
        $this->load->library('../../services/test');
        $ret = $this->test->testando();        
                
        $this->load->view('container');
    }
}
?&gt;

The error returned:

Code:
Fatal error: Cannot redeclare class Test in D:\projetos\paiva\src\site\system\application\services\test.php on line 3

system/application/services/test.php

Code:
class Test {
        function testando () {
            return "shit happens";
        }
    }

The curious side is that if i'm trying to load models, in 'models' path, i dont have any problem, i only have troubles with the 'services' path.

Anyone knows how to load classes in outside directory?

Thanks.


  What is an 'acceptable' Total Execution Time?
Posted by: El Forum - 06-03-2008, 09:11 PM - Replies (12)

[eluser]Lone[/eluser]
Just thought I would put the question out to everyone else here on what they think is an acceptable Total Execution Time for a page.

I am just getting a bit concerned on the time taking to load one of our pages on a clients site - its all ok for now but it there was some heavy track I fear overloading the server.

In my opinion I think an acceptable time is below 0.100 - the page in question is around 0.075. I might be being a little tight here but this is on a server that isn't being worked all that hard, for now, but if it was I am concerned about this execution time.

What times are you seeing on your site?


  Model Confusion
Posted by: El Forum - 06-03-2008, 08:51 PM - Replies (2)

[eluser]mdavis1982[/eluser]
Hi all...

I've been using CodeIgniter for quite a while now, but have always used the ActiveRecord class from the Wiki.

However, I've recently started work on a new project and am a bit confused how to use models properly with database interaction.

For example, in my current project I have a table in my database called 'users'. It has the following fields:

- id
- first_name
- last_name
- e-mail
- password
- web_site
- telephone

When people register on the site, their account is created by an administrator who fills in a form that just has their first name, last name and e-mail address.

How would I go about writing a 'create' method in my User model class, or do I need to do it some other way? With the ActiveRecord class I can just do:

Code:
$this->load->model('user');
$theUser = $this->user->create(array('first_name' => $first_name, 'last_name' => $last_name, 'e-mail' => $email, 'password' => $password, 'web_site' => NULL, 'telephone' => NULL);

However, all the examples I've seen assume that the $_POST array contains values for all fields in the table.

If I then wanted to select a specific member from the database, I could use:

Code:
$this->load->model('user');
$theUser = $this->user->find_by_id(12);

This would return an object of the current user. If I then needed to update the user, I could do:

Code:
$this->load->model('user');
$theUser = $this->user->find_by_id(12);
$theUser->first_name = 'Joe';
$theUser->last_name = 'Blogs';
$theUser->update();

How would I write some equivalent code in my model using the ActiveRecord class?

Also, where is the correct place to put methods that return arrays of objects? For example, in the AciveRecord class I can do:

Code:
$this->load->model('user');
$users = $this->user->find_all_by_first_name('Joe'); // Returns all the records which have a first name as 'Joe'
foreach($users as $user)
{
    echo $user->first_name . ' ' . $user->last_name . '<br />';
}

Sorry for the long post, but I am really confused about this and want to get it right the first time, so that I don't have to rewrite all the code afterwards. Any help would be greatly appreciated!

Thanks guys,

Matt


  Router.php & "/"
Posted by: El Forum - 06-03-2008, 07:31 PM - Replies (12)

[eluser]SplashCreativity[/eluser]
Hey

I'm getting some errors whenever I have a trailing slash on my url.

http://mysite.com/index.php is fine
http://mysite.com/index.php/ gives me errors

Same goes without the index.php, though if I do

http://mysite.com/controller/

It's fine, the routing works fine.

Here are the errors:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/Router.php

Line Number: 190
A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/Router.php

Line Number: 196
A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 0

Filename: libraries/Router.php

Line Number: 199


  Identifying uploaded files with mime type application/octet-stream as images
Posted by: El Forum - 06-03-2008, 07:24 PM - Replies (2)

[eluser]kallus[/eluser]
We had a problem with some devices (playstation portable) setting the mime type to application/octet-stream instead of image/jpeg or image/gif etc. for uploaded image files (hence making the upload library reject the files as non-images). I wrote this code that uses the php extension Fileinfo to read the files magic bytes and replaces the very generic application/octet-stream type with a more specific one. Might be something to add to the CI uploading library. (Downside is that the Fileinfo extension needs to be installed on the server)

Code:
//if mime type is application/octet-stream (psp gives jpegs that type) try to find a more specific mime type
$mimetype = strtolower(preg_replace("/^(.+?);.*$/", "\\1", $_FILES['form_field']['type'])); //reg exp copied from CIs Upload.php
if($mimetype == 'application/octet-stream'){
    $finfo = finfo_open(FILEINFO_MIME, '/usr/share/file/magic');
    if($finfo){
        $_FILES['form_field']['type'] = finfo_file($finfo, $_FILES['form_field']['tmp_name']);
        finfo_close($finfo);
    }
    else echo "finfo_open() returned false");
}

I do this before calling $this->upload->do_upload('form_field'), but it could as well be done in an extension to the uploading library.


  Bug in mysql database library
Posted by: El Forum - 06-03-2008, 07:10 PM - Replies (1)

[eluser]Unknown[/eluser]
The function escape_str has a bug on quote string.
After I added following code,It's ok.

Code:
if (get_magic_quotes_gpc())
{
    return $str;
}


  Sending file path to controller
Posted by: El Forum - 06-03-2008, 05:20 PM - Replies (6)

[eluser]Loque[/eluser]
Hi all,

I have done some searching (probably not looking up the right terms) and i really cant find any information on sending filenames, or varialbes containing '/' to controllers. At the moment I would like to use the force download function, and have an individual controller to handle this, so something super basic like;

Code:
function download($s_name,$s_file)
{
    force_download($s_name,$s_file);
}

and say my link to this would be something like;

www.theSite.com/controllerName/download/filename.jpg/file/path/here/is/never/going/to/work/filename.jpg

I cant think of a way of getting around this other than stripping the slashes and then putting them back in, and that just feels wrong - someone please slap with common sense and help me if you have a mo!

Cheers,
Loque


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

Username
  

Password
  





Latest Threads
SQL server connection not...
by falagar2k
26 minutes ago
Validation | trim
by Gary
39 minutes ago
Problem with session hand...
by Julesb
1 hour ago
External script access to...
by PomaryLinea
1 hour ago
Is it possible to go back...
by Bosborne
2 hours ago
VIRUS reported after Chro...
by InsiteFX
6 hours ago
Codeigniter4 version 4.5....
by kenjis
Yesterday, 04:10 PM
Cannot access protected p...
by xsPurX
Yesterday, 02:10 PM
Update to v4.5.1, same us...
by xsPurX
Yesterday, 08:31 AM
How to use Codeigniter wi...
by kenjis
Yesterday, 05:06 AM

Forum Statistics
» Members: 85,455
» Latest member: joseanthony023
» Forum threads: 77,582
» Forum posts: 376,014

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB