Welcome Guest, Not a member yet? Register   Sign In
  can I improve the speed of log_message
Posted by: El Forum - 09-15-2008, 11:51 AM - Replies (2)

[eluser]vlad_ci[/eluser]
Hi,
while debugging my incomplete app,

I am noticing a constant slow down, when using log_message.

At first I thought that the new code I added caused the visible
slow down

(this is just my dev machine running PHP52.apache.postgres and
my Music player :- )

A soon as I disable logging, pages show up much faster.


I reviewed a couple of postings here, but still did not see
something that I could do -- without modifying internals of code
igniter.

I have seen somewhere a hack to a config.php to allow
to show a particular type of messages (instead of 4 and everything
below it) ... but cannot find it anymore, that would probably help
but not much.

So why is this thing so slow?
appending to a file of 50 lines per request cannot be that slow,
locking the file... I doubt (it is a local file system).
Does CI do 'lock file,seek,write' or someething like that for every single time I invoke the log_message?

So there may be a different way to pass messages to the log so
it goes faster? May be there something like 'flush log' that
could put at the destructor of the Controller class, so that writting
locking/writting would happen only once per request?



thank you


  Problem with instance of CI database class
Posted by: El Forum - 09-15-2008, 09:11 AM - Replies (3)

[eluser]LuckyFella73[/eluser]
hello all,

I have a problem working with an instance of the CI database class.

I followed a tutorial of "Bramme" -> a basic login class (named "Auth").
In the class (Auth.php) an instance of the database class is loaded:

Code:
# first lines cut
function Auth($props = array())
    {
        $this->CI =& get_instance();
        
        # Load additional libraries, helpers, etc.
        $this->CI->load->library('session');
        $this->CI->load->database();
# rest fo code here

Within one function, I'm able to access my database, for example:
Code:
$this->CI->db->where('vorname', $this->vorname);
        $this->CI->db->where('nachname', $this->nachname);
        $this->CI->db->where('mitgliedsnummer', $this->mitgliedsnummer);
        $this->CI->db->where('geburtsdatum', $this->geburtsdatum);
        
        $query = $this->CI->db->get($this->usertable);

I added a method to the class (a set new password function) and can't access
the db anymore using the same synthax. In the new method I tried:
Code:
$this->CI->db->where('mitgliedsnummer', $this->session->userdata('mitgliedsnummer'));

I just get an error message at this line:
Quote:Fatal error: Call to a member function on a non-object in ...


Any ideas what I'm doing wrong?


  Please help, loading a view from controller does not work!!!
Posted by: El Forum - 09-15-2008, 07:50 AM - Replies (5)

[eluser]smnirven[/eluser]
Hello all,

I am having a problem loading a view within one of my controllers. Basically, I have an insert function that is the handler for a form of mine. Inside the insert function I check that the posted values from the form are not null or blank. If I find a required field that is null or blank, I want to return to the form and pass it an error message to display on the form. Here is the code that is not working:

Code:
// First check required fields
if (!isset($_POST['noteSubject']) || $_POST['noteSubject'] == '')
{
    $sql = "INSERT INTO debug_info (text, timestamp) VALUES ('WTF1', NOW())";
    $this->db->query($sql);
    $data['error'] = "Subject is a required field";
    $this->load->view('create_note_view', $data);
}

$sql = "INSERT INTO debug_info (text, timestamp) VALUES ('WTF2', NOW())";
$this->db->query($sql);

When I submit the form without entering anything into the ‘noteSubject’ field, it never makes it back to the form (create_note_view) like I wanted. Also, when I look at my debug_info table, I see both the “WTF1” and “WTF2” message. Can anyone explain this and help me out how to fix this?

Thanks!


  [SOLVED] Example Web site.
Posted by: El Forum - 09-15-2008, 07:30 AM - Replies (7)

[eluser]TheFuzzy0ne[/eluser]
Hi everyone.

I'm having a serious problem here. I'm trying to design a bespoke Web site for a company which sells candy. I have designed a template, and know exactly what I want to do, but I can't seem to get the structure right, and as a result, coding is becoming very complex. The problem I am having is with the structure. I am trying to come up with a simple way to display pages, which in itself seems like a simple question, but I am finding that my code is a lot more bloated than it needs to be as I am having to define lots of variables within the controller, such as the page title, header variables, footer variables, navigation menu title and contents etc...

I have been thinking about using models, and having a model for each page which will hand back the variables for the template, but the bloat is still there, just not in the controller. Also, with views, I am finding that I have lots of fragments, which is bloating the directory structure. I think my problem here is simply organisation. I think I try to keep things lean in the early stages of a project, which complicates it more for me. But I know there is a way to keep my code lean, without having to complicate things like I am.

I've tried to find an example of a whole Web site, so I can try and figure out how I should structure everything, but the only thing I seem to be able to find is example applications. I have no problem creating applications, it's integrating them together into one site I am struggling with.

I have an admin section too, and the controller is getting bloated, so I need to break it up into other controllers. I'm not sure how to handle a user accessing the controller who is not admin. Should the constructor redirect them away from the pages? Do I need to create a function that's called upon within each controller function? Should the function even redirect the user? I have lots of ideas, and I can never decide which one to go with, so any pointers here would really help me.

Would anyone have any pointers, or know of any URLs where I might be able to download a complete Web site, rather than just a single application? I know it's a really big question, and everyone has their own way of programming, so often there is not only one correct way of doing things, but I know I am going about this project the _wrong_ way, and I need to get myself back on the right track before continuing further.

Thanks in for reading. I'd appreciate any replies.

EDIT: I'd also like to know how I should handle multiple translations of the same document, but with large documents, for example, Privacy Policy, or About Us. I have no problem translating strings, I'm just not sure how I should handle larger amounts of data. Does CI support this natively, or do I need to emlpoy one of my ugly hacks?


  mixed URL's
Posted by: El Forum - 09-15-2008, 06:13 AM - Replies (14)

[eluser]Unknown[/eluser]
Hi all!
I am searching the right way... =)
How can I use this url, for example,
http://example.com/controller/method/?pa...&par2=val2 ... etc
I like CI scheme /controller/method/arguments_1/arguments_2
But best way (sometimes) is use mixed url...

is it possible with CI help ??

sorry for my ugly English (


  "<?=" does not work for me.....
Posted by: El Forum - 09-15-2008, 05:56 AM - Replies (1)

[eluser]Mr Lazy[/eluser]
Hello,

I have been trying to set up the layout for my first CodeIgniter site, and I hit the annoying snag that when outputting into a master layout template, this worked:

Code:
<!-- Displays the main content for the page. -->
<?php echo $content; ?>

but this did not..

Code:
<!-- Displays the main content for the page. -->
<?= $content ?>

nothing was outputted at all. What is going on here?

Many Thanks,
L


  Stikked V. 0.5.1
Posted by: El Forum - 09-15-2008, 03:27 AM - Replies (1)

[eluser]benofsky[/eluser]
For those of you that don't know. Stikked is a pastebin application I wrote, originally to provide a full example application for CodeIgniter. It has since grown past that and is now a fairly decent service (http://www.stikked.com). Despite that it is also still a great example application.

Stikked has just been updated to v. 0.5.1. With lots of code improvements and a few new features; such as Paste Replies, Downloads, The ability to view a paste in fluid width in a fixed width design (you have to look at it to get what I mean) and lots more.

So I encourage anyone looking for example CodeIgniter code to check it out at http://code.google.com/p/stikked.

Thanks!
Ben


  Joined rows in mdate() function?
Posted by: El Forum - 09-15-2008, 03:11 AM - Replies (1)

[eluser]Joakim_[/eluser]
I have a model where todays entries are shown for the user. However, I want the user's time-zone and daylight settings to be considered. I have tried to join these settings from the account table but I don't know how to include them in the mdate() function.

I've tried with the code below but it wont work:

Code:
function todays_posts()
    {
        $this->db->select('*');
        $this->db->from('posts');
        $this->db->join('accounts', 'account_id = post_account_id');

        $this->db->where('DAY(FROM_UNIXTIME(post_date))', mdate('%d', gmt_to_local(now(), 'accounts.timezone', 'accounts.daylight')));    
        
        return $this->db->get();
    }

Any help are much appreciated. Thank you very much! Smile


  yet another datamapping for CI : orm5
Posted by: El Forum - 09-15-2008, 03:07 AM - Replies (2)

[eluser]Dready[/eluser]
You heard about
http://ellislab.com/forums/viewthread/90181/ DataMapper
http://ellislab.com/forums/viewthread/89314/ Datamapper ORM class
http://ellislab.com/forums/viewthread/88688/ simpleORM
http://ellislab.com/forums/viewthread/78305/ IgnitedRecord
http://codeigniter.com/wiki/ActiveRecord_Class/ ActiveRecord
right ?

As a fashion victim I couldn't resist writing my own Datamapping orm'ing addon for CI !

ORM5 is a PHP5 only CI addon. By using the power of PHP __set, __get and SPL, I end up with a simple and (I hope) powerfull solution.
I don't use the singular/plural mess, and make no distinction between one to one and one to many relationships : the first being a particular case of the latter.

A little example :

Inside your controller :

Code:
//getting all posts from user 'John'
foreach ( $this->orm5factory->where('name','John')->get('users')->posts as $post ) {
    echo $post->title." on ".$post->date;
}

//the same thing ordered by date please
foreach ( $this->orm5factory->where('name','John')->get('users')->order_by('date')->posts as $post ) {
    echo $post->title." on ".$post->date;
}

//getting all tags related to all posts from user John
foreach ( $this->orm5factory->where('name','John')->get('users')->posts->tags as $tag ) {
    echo $tag->name."<BR>";
}

//getting users having tagged their posts with at least one of the tags user John used in these posts:
foreach ( $this->orm5factory->where('name','John')->get('users')->posts->tags->posts->users as $user ) {
    echo $user->name." used at least one of the tags of John's posts !<BR>";
}

//setting tags for post id 34
$tag_object = $this->orm5factory->get('tags');
// $tag_object is an empty (no record) object of class tags
$newtags = $tag_object->create( array('name'=>'something'));
$newtags->merge($tag_object->create( array('name'=>'something else')));
//here $newtags contains two records (table rows)
//setting tags
$this->orm5factory->where('id',34)->get('posts')->tags = $newtags;
//or adding tags to existing ones
$this->orm5factory->where('id',34)->get('posts')->tags = $this->orm5factory->where('id',34)->get('posts')->tags->merge($newtags);

Documentation and rc1 download can be found here : http://dready@byethost31@com/index.php/display/view/135 (please replace @ with . as CI forums backlist this url :-( and our community chieftain is on vacation)

Hope you'll like it


  Form problem
Posted by: El Forum - 09-15-2008, 01:21 AM - Replies (3)

[eluser]dimis[/eluser]
I have a form and some inputs for languages.
For each language I have name[en],name[gr] etc.
These names as dynamically created from a database.
When I submit this form there is the message Disallowed Key Characters even I do not assign the post elements.
How can I resolve it or how I can pass these elements that i can not create them statically?


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

Username
  

Password
  





Latest Threads
Trying to remove index.ph...
by kabeza
28 minutes ago
Reading a session variabl...
by LP_bnss
37 minutes ago
CI NEEDS A PROPER DOCUMEN...
by codestellar
43 minutes ago
Gateway time out CI 4.4.1
by adleon73
2 hours ago
CodeIgniter 3 to 4 migrat...
by kenjis
2 hours ago
Background image does not...
by ozornick
3 hours ago
Implement DDD in Codeigni...
by InsiteFX
6 hours ago
Issue with Model Validati...
by kenjis
8 hours ago
What should I do to show ...
by kenjis
8 hours ago
error is logged. but it d...
by kenjis
11 hours ago

Forum Statistics
» Members: 86,807
» Latest member: anjkuc2
» Forum threads: 77,625
» Forum posts: 376,225

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB