Welcome Guest, Not a member yet? Register   Sign In
  Language files in database
Posted by: El Forum - 04-11-2008, 02:45 AM - Replies (1)

[eluser]Unknown[/eluser]
Hi all,

I searched for a while now, but I cannot find anything here in the forums about this:

Does anybody use the database for language data storage instead of the files?

I need the strings in a database as I need to be able to export and versionalize them for our external translation service. I first thought about simply importing the lang files into a database and export them again afterwards, but it seems simpler to use the strings directly.

I don't think that this is too complicated, but maybe somebody has already done so and I don't have to reinvent the wheel.

Thanks in advance,
DD


  Get value of "Last " URI / URL segment with total_segments
Posted by: El Forum - 04-11-2008, 02:41 AM - Replies (3)

[eluser]geshan[/eluser]
A code like below:

Code:
//in library
$ts=$this->CI->uri->total_segments();
$offset= $this->CI->uri->segment($ts);    

//in controller
$ts=$this->uri->total_segments();
$offset= $this->uri->segment($ts);

This gives you the value of the last segment of your URL, it is very useful when you paginate and need the value of the offset.

Geshan


  Pagination in library file return blank result
Posted by: El Forum - 04-11-2008, 01:52 AM - Replies (1)

[eluser]geshan[/eluser]
I'm working on a library for something I want to paginiate the results of a SQL query.

I've loaded he pagination library in the constructor of the library.

Code:
$this->CI->load->library('pagination');

//and other needed variables

$this->controller = $this->CI->uri->segment(1);
// Set the base URL
$this->base_url = $this->CI->config->site_url().'/'.$this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'both');

//assume total_rows also has value say 10 and query is running OK.

I just need a function to get the pagination links that I can send to the controller as an array element like

Code:
$query_res['paging_links']=paginate(5); //5 is per page results

The paginate function that return me nothing is:

Code:
function paginate($page_size){
        
        //LIMIT ".$offset.",".$perpage);
         $config['uri_segment'] = 4; //$this->CI->URI->total_segments();
         $config['base_url'] = $this->base_url;
         $config['total_rows'] = $this->total_rows;
         $config['per_page'] = $page_size;
         $config['num_links'] = 5;
    
         $config['full_tag_open'] = '<div id="pagination">';
         $config['full_tag_close'] = '</div>';
    
    
         $config['first_link'] = '<< Start';
         $config['last_link'] = 'End >>';
         $config['next_link'] = 'Next >';
         $config['prev_link'] = '< Prev';
    
         $this->CI->pagination->initialize($config);
        
        $paging_links=$this->CI->pagination->create_links();
        echo "<br><br>Paging links in paginate has: ".$paging_links;
        return $paging_links;
    }//function paginate close

Above paginate function used to work ok in a controller, Whats wrong with the above code, please help...


  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

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

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

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.


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

Username
  

Password
  





Latest Threads
How to run a single seede...
by kenjis
4 hours ago
directory structure
by kenjis
4 hours ago
Codeigniter 4 extend core...
by kenjis
4 hours ago
Redirect with error vali...
by kenjis
4 hours ago
blocked by CORS policy
by kenjis
4 hours ago
Showing pdf on browser
by aarefi
6 hours ago
[CodeIgniter 4 on IIS 10]...
by Bosborne
9 hours ago
[4.5.1] Disabling the deb...
by ozornick
Today, 08:02 AM
problem with textarea
by padam
Today, 07:31 AM
Upgrade from CI3 to CI4 -...
by mkganesh
Today, 03:29 AM

Forum Statistics
» Members: 84,198
» Latest member: CaratBee
» Forum threads: 77,553
» Forum posts: 375,862

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB