Welcome Guest, Not a member yet? Register   Sign In
  Class referencing appears a memory leak
Posted by: El Forum - 10-31-2007, 10:53 AM - Replies (7)

[eluser]dyron[/eluser]
Hi,

now I'm develop for a while with CI. Nice Framework, but still some places for improvements.

After I work on a handball website, my system ran low and my browser crashed. Looking at the task manager shows me a storage allocation of 900MB! for firefox and 300MB! for apache. This isn't normal.

For debugging I created a helper which contains:

Code:
function debug()
{
  echo "<pre>\n";
  var_dump(func_get_args());
  echo "</pre>\n";
  die();
}

I used this for displaying $this. This was a experience.
Firebug notifies that this HTTP request causes 200MB traffic before arriving the PHP maximum_execution_time of 30 secs.
Most of the "$this" content was absolutely redundant, e.g. more than 50 CI_Config references.

Does anybody know, how I kept $this thin and clean?
I think it's a problem with
Code:
$CI =& get_instance();
in functions or
Code:
$this->CI =& get_instance();
in classes.

I use PHP 5, however I read & is deprecated. Should I use
Code:
$CI = get_instance();
instead?

My CI version is 1.5.4.

Anybody noticed such characteristics?

Regards dy


  escaping null values
Posted by: El Forum - 10-31-2007, 08:27 AM - Replies (11)

[eluser]ken_t[/eluser]
hi, i just started working with frameworks and im not a pro php programmer.
So i dont know if im doing something wrong.

In my application i have a function that insert at a db some values from the view input fields.
There are some int type fields at this table as for example the age field.

Im using $this->db->insert(table,values) function.

And when i leave the age input field null and submit the form, the escape function treats it as string and escape it.

Then i get a db error saying invalid value for int "".

I edited the escape function at db_driver.php to make it not escape null values. Is there another way for it?


  Problem with the controller url
Posted by: El Forum - 10-31-2007, 06:56 AM - Replies (3)

[eluser]tirithen[/eluser]
How come

"http://visarkiv.hinfitt.se/index.php?blog" works and
"http://visarkiv.hinfitt.se/index.php/blog" does not

Would this be a setting on the web-server? Unfortunently it's a commercial server so I can't change any settings.


  Unable to locate the model
Posted by: El Forum - 10-31-2007, 05:57 AM - Replies (3)

[eluser]Jim-Bingo[/eluser]
When I load my firstpage I get this message:

Quote:An Error Was Encountered

Unable to locate the model you have specified: startmodel

My controller start.php:
Code:
&lt;?php
class Start extends Controller {
        
    function index()
    {
          $this->load->model('startmodel');
          $news['news'] = $this->startmodel->get_last_three_news();
          $data = array(
               'title' => 'Malungs OK SkogsmÃ¥rdarna',
               'content' => $this->load->view('content/start',$news,true)
          );
  
          $this->load->view('layout/main',$data);
    }
        
}
?&gt;

My model Startmodel.php:

Code:
&lt;?php
class Startmodel extends Model {

    function Startmodel()
    {
         parent::Model();
    }
    
    function get_last_three_news()
    {
        $query = $this->db->get('tbl_news', 3);
        return $query->result();
    }
    
}
?&gt;

Anybody knows whats wrong?


  Email over SMTP is sent, but CI returns false
Posted by: El Forum - 10-31-2007, 04:12 AM - Replies (2)

[eluser]Daniel Kvasnicka jr.[/eluser]
Hi people,
CI is a wonderful thing, I switched from CakePHP and I like the way CI does not stand in my way and yet it serves me with many useful classes.

However, I have a weird problem with sending e-mail over SMTP. The email is sent, but CI's send() method returns FALSE. The first problem is, that it shows SMTP's 220 Service ready response as an error (with "The following SMTP error was encountered" before it). And the second problem is "354 Enter mail, end with "." on a line by itself". Is this some kind of incompatibility between CI's mail class and some mailservers' specific configs? (ESMTP Sendmail 8.13.6/8.13.6.)

Message sent was:

Code:
User-Agent: CodeIgniter
Date: Wed, 31 Oct 2007 11:08:45 +0100
From: "dan"
Return-Path:
To: [email protected]
Subject: Test mail
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Testing

(the real address was exchanged for "[email protected]" so that crawlers don't find it here)


  AdBrite/AdSense clone
Posted by: El Forum - 10-31-2007, 12:09 AM - No Replies

[eluser]Unknown[/eluser]
Hello. First of all hi everybody. I'm new to CI (like month of watching through manuals, examples etc). And I'm here to get some help if possible =)

So, as you probably can see from the topic I'm working on an AdBrite/AdSense clone. And the main question now is - has anyone got some examples of how to write such thing using CI? Of course I can do it myself to ... But just thought that I'll post here and see if someone can help =)

Any help is much appreciated. Thank you.


  Interesting Load of CI from an external class
Posted by: El Forum - 10-30-2007, 10:26 PM - No Replies

[eluser][email protected][/eluser]
Hey guys, I am trying to load the CI framework from an external class. The framework is loading fine with no errors in the logs.

I am trying two scenarios here, and for scenario #1, am getting result: "12"

&lt;?php
require_once('../../../simpletest/unit_tester.php');
require_once('../../../simpletest/reporter.php');
require_once('../../../index.php'); //Load CI Framework

class admin_model_test extends UnitTestCase {

function testGetAllDesigns() {

echo '1';
$CI =&get;_instance();
echo'2';
$CI->load->model('admin_model');
echo '3';
$arr = $CI->admin_model->getAllDesigns();
echo '4';
$this->assertTrue(true);
echo '5';
}
}

if(TESTING=='TESTING') {
$test = & new admin_model_test();
$test->run(new HtmlReporter());
}
?&gt;

For scenario #2 (comment out CI stuff), I am getting "12345", and then the test case result.

&lt;?php
require_once('../../../simpletest/unit_tester.php');
require_once('../../../simpletest/reporter.php');
require_once('../../../test_index.php');

class admin_model_test extends UnitTestCase {

function testGetAllDesigns() {

echo '1';
//$CI =&get;_instance();
echo'2';
//$CI->load->model('admin_model');
echo '3';
//$arr = $CI->admin_model->getAllDesigns();
echo '4';
$this->assertTrue(true);
echo '5';
}
}

$test = & new admin_model_test();
$test->run(new HtmlReporter());

?&gt;

Currently, the "&get;_instance()" is returning the default_controller class (Home Class). How can I get it to return the CI base class, and then call a ($CI->load->model(...)) on it?


  How to run CI in subdirectory?
Posted by: El Forum - 10-30-2007, 10:05 PM - Replies (3)

[eluser]Unknown[/eluser]
Hi, everybody:

I've met a problem. I installed the CI in a subdirectory on my web server. The directory structure listed below

http://domainname/
http://domainname/admin/

The path "/admin/" is a real directory in my filesystem and related to webroot dir, like this:

/domainname <- my webroot dir.
/domainname/admin/ <- CI installed path

I put .htaccess in CI installed path:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /admin/
    RewriteCond %{REQUEST_FILENAME} !-F
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

My ci config is:
Code:
$config['base_url']    = "http://domainname/admin/"
$config['index_page'] = "";

I could run "http://domainname/admin/" but couldn't run controller like "http://domainname/admin/profile/changepw/".

I don't know how to make it work.


  Quick route question
Posted by: El Forum - 10-30-2007, 09:46 PM - Replies (1)

[eluser]Unknown[/eluser]
I'm building a site that has a few Controllers for hard-coded 'modules' as well as a fairly simple 'CMS' style pages Controller.

My idea was to have URL paths like:

Code:
site.com/module1/action/...
site.com/module2/action/...
Which route in the normal controller/function/param fashion and anything else is a 'CMS' page:
Code:
site.com/about-us
site.com/contact-us
Which would map to site.com/pages/page/about-us, site.com/pages/page/contact-us.

So far I've come up with something like this in routes.php:
Code:
$route['module1'] = 'module1';
$route['module1/(.*)'] = "module1/$1";
...
$route['(.*)'] = "pages/page/$1";
Am I on the right track here?


  How to check if file exists via URL
Posted by: El Forum - 10-30-2007, 09:45 PM - Replies (7)

[eluser]codex[/eluser]
When you try to get a file that doesn't exist you get the 'failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found'-error, but how do you prevent this? I'm using file_exists to check if a file is present, but it chokes on the 404.

For instance

Code:
http://img.youtube.com/vi/XgdmsJsOKJc/2.jpg
is valid, while
Code:
http://img.youtube.com/vi/jksfhjhfjfdjsfjdsjhjhfd/2.jpg
isn't.

How do you check the validity??


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

Username
  

Password
  





Latest Threads
Version number stays un-u...
by trunky
2 hours ago
codeigniter4/queue Not lo...
by mywebmanavgat
7 hours ago
Array to HTML "Table"
by HarmW94
8 hours ago
shortcodes for ci4
by xsPurX
9 hours ago
TypeError when trying to ...
by b126
Today, 12:04 AM
Webhooks and WebSockets
by InsiteFX
Yesterday, 10:39 AM
Retaining search variable...
by pchriley
Yesterday, 05:46 AM
Reading a session variabl...
by xanabobana
Yesterday, 05:05 AM
Update to v4.5.1, same us...
by kenjis
04-17-2024, 07:47 PM
Codeigniter 4 extend core...
by Semsion
04-17-2024, 05:08 AM

Forum Statistics
» Members: 84,589
» Latest member: untung22me
» Forum threads: 77,560
» Forum posts: 375,900

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB