Welcome Guest, Not a member yet? Register   Sign In
  How can you make $this->validation->THISPART_error dynamic?
Posted by: El Forum - 04-11-2008, 12:16 AM - Replies (3)

[eluser]codex[/eluser]
The object is to change THISPART (if it wasn't clear). Is it possible?

EDIT: never mind :coolsmirk:


  Cant I declare global varirable in controller?
Posted by: El Forum - 04-10-2008, 11:45 PM - Replies (4)

[eluser]geshan[/eluser]
The following code shows error:

Code:
class Testlibc extends Controller{

    $sql_q="SELECT * from del_user"; //it gives error here
    
    function testlibc(){
        parent::Controller();
        $this->output->enable_profiler(TRUE);
        $this->load->library('testlib',$sql_q);
    }
    
    function index(){
        $this->grid_construct($sql_q);
                    
    }//function index close
}//class close

How can I declare global variable in a contoller?


  Bad problem with transactions freezing entire app
Posted by: El Forum - 04-10-2008, 11:33 PM - Replies (2)

[eluser]kirilisa[/eluser]
This is actually similar to this thread but since that hadn't been touched in a while I decided to start a new thread.

Transactions are fundamental to my app. In an attempt to make sure transactions were working properly on txn failure, I came across what I feel is a bug. Here is code for purpose of demonstration:

Code:
class Test extends Controller {
  function __construct()
  {
    parent::Controller();        
  }

  function one() {
    $this->db->trans_begin();
    $this->db->query("update SystemUser set lastName = 'blah1' where userName = 'cmiuser'");
    $this->db->query("BAD QUERY");

    if ($this->db->trans_status() === FALSE) {
      echo "rollback one";
      $this->db->trans_rollback();
    } else {
      echo "committed one";
      $this->db->trans_commit();
    }    
  }

  function two() {
    $this->db->trans_begin();
    $this->db->query("update SystemUser set lastName = 'blah2' where userName = 'cmiuser'");

    if ($this->db->trans_status() === FALSE) {
      echo "rollback two";
      $this->db->trans_rollback();
    } else {
      echo "committed two";
      $this->db->trans_commit();
    }    
  }
}

1) typing 'show processlist' at mysql cmd line shows no active threads but the processlist

2) in web browser, browse to localhost/ci/test/one. PHP dumps an error:
An Error Was Encountered
Error Number: 1064
You have an error in your SQL syntax;
BAD QUERY

3) reload the page localhost/ci/one or go to localhost/ci/two: it hangs forever, eventually quitting with an error:
An Error Was Encountered
Error Number: 1205
Lock wait timeout exceeded; try restarting transaction
update SystemUser set lastName = 'blah1' where userName = 'cmiuser'

4) type 'show processlist' at mysql cmd prompt. it says:
Code:
mysql> show processlist;
+----+----------+----------------+-------+---------+------+----------+---------------------------------------------------------------------+
| Id | User     | Host           | db    | Command | Time | State    | Info                                                                |
+----+----------+----------------+-------+---------+------+----------+---------------------------------------------------------------------+
| 14 | root     | localhost      | fcprd | Query   |    0 | NULL     | show processlist                                                    |
| 23 | kirilisa | mojojojo:42272 | fcprd | Sleep   |   96 |          | NULL                                                                |
| 24 | kirilisa | mojojojo:42274 | fcprd | Query   |   30 | Updating | update SystemUser set lastName = 'blah1' where userName = 'cmiuser' |
+----+----------+----------------+-------+---------+------+----------+---------------------------------------------------------------------+

i.e. because PHP crashed with a mysql error about my bad query, it never got around to the $this->db->trans_rollback(); bit of the controller, and so that table is now locked up for good.

The only way to unlock it is to kill all the listed processes or restart the DB.

Granted one would hope that SQL statements wouldn't be crashing with PHP errors, but it seems to me that even if they do, CI's database abilities should be able to handle this without resulting in this locked table problem.

I don't know what to do about this. I thought putting a $this->trans_rollback(); in the beginning of the trans_begin() function might fix it, but it did not. Help!

[I honestly don't understand why it is even dumping the mysql error to screen as I have log_errors set to Off in my php.ini and I see all the mysql functions in mysql_driver are using @, but that's an unrelated issue. I'd really just like to understand how to make CI rollback transactions on PHP/mysql error that halts the code execution.]

I am using PHP 5.2.3 on ubuntu gutsy, MySQL 5.0.45, CI 6.1 with the bundled DB library.

Any help would be most appreciated. I'm a bit stressed about this transaction thing. Thanks!


  try help me with this error
Posted by: El Forum - 04-10-2008, 08:48 PM - Replies (6)

[eluser]ejanmapet[/eluser]
i have try 2 follow login form tutorial..but i've got this error

Fatal error: Class 'Base_Model' not found in C:\wamp\www\try\system\application\models\Users_model.php on line 3

and this is the code i'm using in model

this is user_model file

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Users_model extends Base_Model
{
function Users_model()
{
parent::Base_model('users');
}
}
?>

this is base_model file

class Base_model extends Model //required by all models
{
var $table, $resultset, $select;

function Base_model($table = NULL)
{
parent::Model();
$this->table = $table;
$this->resultset = array();
$this->select = '*';

log_message('debug', "Base_model initialised as {$this->table}");
}

can i get some idea y i got this bug..really appreciate...thanks..


  force_download cutting off last few lines
Posted by: El Forum - 04-10-2008, 08:02 PM - Replies (1)

[eluser]dmorin[/eluser]
I'm creating a dynamic ics file and using the force_download helper to download it, however, the force_download helper is cutting off the last few lines. If I just echo the content directly to the screen, it's all there so it is definitely the download portion.

The only idea I have had is that it might have to do with the multi-byte characters that are included in the string, however, I'm overloading the strlen php function with mb_strlen and I even tried substituting it with mb_strlen in the download helper and that didn't work. I also tried manually adding in an encoding type of UTF-8 to the header and still nothing.

I saw one other post where someone else had this issue, but they didn't seem to find a solution. If anyone has any ideas, please let me know. Thanks.


  Date Format
Posted by: El Forum - 04-10-2008, 05:26 PM - Replies (2)

[eluser]Kemik[/eluser]
Hey,

Say if I'm using date and time a lot in my application, subtracting, adding and comparing them, which format would you recommend? Unix or MySQL?

Thanks. To give you an idea it's for a calendar and todo list. E.g. x days to complete y. Find tasks between x and y dates.


  Help with URI routes
Posted by: El Forum - 04-10-2008, 05:14 PM - Replies (2)

[eluser]Temple[/eluser]
Hey All, been using CodeIgniter for a while now. A lot of my controllers are getting big, and I read you can use a folder within the application/controllers folder to break the functions down to single pages instead of a big one.

This is fantastic however, is there a way to keep routing the same even though it is a folder? What I mean is, default behavior is:

Code:
http://www.url.com/class/function/id/

However, if my controller is a folder, it becomes:

Code:
http://www.url.com/folder/class/function/id/

Is there a way to keep the URI routing as the default non folder behavior? Because of the class, it seems hard to me Sad

Thanks in advance for all replies.


  where() doesn't add the table_prefix if you include an operator in the first parameter
Posted by: El Forum - 04-10-2008, 01:07 PM - Replies (2)

[eluser]Thoer[/eluser]
Example:
1. Have a table named 'bd_test' with a column 'test' in it.
2. Make sure you make 'bd_' your db prefix

Code:
$this->db->where('test.test', '1');
$this->db->get('test');
echo $this->db->last_query();
will output:
Quote:SELECT * FROM (`bd_test`) WHERE bd_test.test = '1'

Code:
$this->db->where('test.test!=', '1');
$this->db->get('test');
echo $this->db->last_query();
will output:
Quote:An Error Was Encountered

Error Number: 1054

Unknown column 'test.test' in 'where clause'

SELECT * FROM (`bd_test`) WHERE test.test!= '1'

* I hope it hasn't been sentenced yet.


  image plugin
Posted by: El Forum - 04-10-2008, 11:51 AM - Replies (2)

[eluser]steel_slasher[/eluser]
this is my first contribution the the CI development/expansion basically i wanted to load images in HTML without all the slashes and speech marks so i thought i would make a helper at first but realised i would only need one function so i moved to a plug-in.

Basically you load the plug-in like so:

Code:
$this->load->plugin('image');

and to output the image HTML you use this function:
Code:
$file = "myimage.gif";
$path = "/images";
echo image($file, $path);
//outputs <img url="/images/myimage.gif" />

a default path can be set in the plugin file itself (this bit needs testing at the min):
Code:
&lt;?php

function image($name, $path="/system/images/")
    {
        foreach ($name as $file){
            echo "<img url=\"". $path. $file. "\" />";
        }
    }

?&gt;
to the best of my knowledge of php functions you can set the default path by changing
Code:
$path="/system/images/"
to
Code:
$path="/whatever/folder/youwant/"
a trailing and leading slash MUST BE USED!

if you want to use the default path just call the function with the file variable
Code:
$file = "myimage.gif";
echo image($file);

if you want to load several images then an array can be used
Code:
$files= array("file1.gif", "file2.gif", "file3.gif");
echoimage($files);

here is the source:
Code:
&lt;?php

function image($name, $path="/system/images/")
    {
        foreach ($name as $file){
            return "<img url=\"". $path. $file. "\" />";
        }
    }

?&gt;

if there are any problems please say and also i am planning to expand to cover other media types like flash but then it would become a helper.

Download it here:
http://sitecrackerz.wordpress.com/2008/0...-app-ever/


  Building global permissions.
Posted by: El Forum - 04-10-2008, 10:50 AM - Replies (4)

[eluser]Young Caveman[/eluser]
As usual, i apologize cause i can't speak english very well, but i'll try to explain as well as i can.
I'm new with CI, i would like to know if i can do this thing without coding too much.

Suppose i have to restrict the controller "admin", only the administrator can access to this area. Sure, he's the only who can access also admin/some, admin/somethingelse etc.

I have to code a if in each 'index', 'some' and 'somethingelse' function, or i can do something here? :

Code:
function Admin()
    {
        parent::Controller();
            
    }
Something here would help me in every function of the controller?

Thanks in advance.

Don ~ Alberto.


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

Username
  

Password
  





Latest Threads
Codeigniter4 version 4.5....
by kenjis
2 hours ago
SQL server connection not...
by kenjis
2 hours ago
Problem with session hand...
by kenjis
2 hours ago
Is it possible to go back...
by kenjis
2 hours ago
Cannot access protected p...
by xsPurX
4 hours ago
Update to v4.5.1, same us...
by xsPurX
9 hours ago
How to use Codeigniter wi...
by kenjis
Today, 05:06 AM
CVE-2022-40834 SQL Inject...
by kenjis
Today, 03:44 AM
Retaining search variable...
by pchriley
Today, 03:15 AM
Disable debug output in v...
by groovebird
Today, 02:26 AM

Forum Statistics
» Members: 85,378
» Latest member: thalitaken066
» Forum threads: 77,581
» Forum posts: 376,007

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB