Welcome Guest, Not a member yet? Register   Sign In
  mysql between dates function
Posted by: El Forum - 10-19-2007, 09:29 PM - No Replies

[eluser]megabyte[/eluser]
OK, I've succesfully done this, until I figured out it only works if your current date can allow a 10 days to be subtracted.

How do you do this so it wouldnt matter what date it was?



here's what I got, which is limited if its the first of the 10th of the month or less.

Code:
function _show_web_stats()
    {
    $this->db->select('UserId, date_format(Date,\'%Y-%m-%d\') as Date, count(Date) as Visitors, SUM(Hits) as NoOfHits');
    $this->db->groupby("Date");
    $this->db->where('UserId', $this->userid);
    $then = date('Y-m-d', now());
    $then = explode('-', $then);
    $then[2] = $then[2] - 15;
    $past = implode('-', $then);
    $this->db->where("Date between '$past' and 'Date' ");
    $this->db->orderby("Date", "asc");
    //returns the query string
    $query = $this->db->get('WEB_stats');
    
    return $query;
    }


I need help, lol. I've searched the net and hit a learning curve here.


  Multidimensional session data
Posted by: El Forum - 10-19-2007, 05:05 PM - No Replies

[eluser]spheroid[/eluser]
How is it possible to do the following refactored for CI? Having difficulty compared to the documentation:

1. Increase the value by 1

Code:
$_SESSION['cart_product_qty'][$i]++;

2. Compare a multidimensional session array key
Code:
if ($_SESSION['cart_product_id'][$i] == $product_id) ...

3. Set a session variable using an array key
Code:
$_SESSION['cart_product_qty'][] = 1;

4. Display a multidimensional session variable
Code:
echo $_SESSION['cart_product_qty'][$i];

I'm not sure if it's possible to use these type of multidimensional session variables??


  How to "install" xajax in CodeIgniter??
Posted by: El Forum - 10-19-2007, 04:46 PM - No Replies

[eluser]Unknown[/eluser]
hello!!
i have been trying out the xajax library in CodeIgniter and always a got this error

Quote:Fatal error: Call to undefined method xajax::processRequests()
it don't recognize the processRequests() function... i don't know what to dou to fix it...
anyone could help me to use or "instal" tha xajax library in CodeIgniter... i got the full package of xajax 0.5 beta 4... How to "install" xajax in CodeIgniter!!


  CI & IIS: Selects the controllers right, but doesn't execute the code?
Posted by: El Forum - 10-19-2007, 03:48 PM - No Replies

[eluser]jimmy0x52[/eluser]
Hi,

I've got CI running on IIS. I've got it running with ISAPI_rewrite and can successfully access my controllers using

http://www.website.com/index.php/controllername

The problem is the controller contents come up and are not rendered/executed by PHP/CI. I get the actual code spit out at me.

Does anyone have any ideas why this is? I've got PHP installed as an ISAPI module with the correct web service extensions - and I know that rewrite is working because I can switch between controllers - it just will not render the output once it's grabbed from the controller.

Anyone have this issue as well? I can't seem to find an answer.


  posting the latest of something to the top of the row
Posted by: El Forum - 10-19-2007, 02:24 PM - No Replies

[eluser]mdriscol[/eluser]
Hi, I'm new to this.

I have a page displaying data from a table with foreach($announcements->result() as $row):

When its displayed each new row is displayed below the oldest but I want to do that in reverse order. The newer posts need to be on the top instead of the bottom of the table.

How can I accomplish this?

Should I be using a function that reorders the table in the database or a function that displays foreach in reverse on the view?


  Routes: how to get mycontroller/id function same as mycontroller/action/id
Posted by: El Forum - 10-19-2007, 10:26 AM - No Replies

[eluser]dreamynsx[/eluser]
Hello, I've read routes documentation already, but it really does not have a lot of examples for what I'm trying to do. Please help.

Code:
// my sample class with index action
class MyController extends Controller
{
    function index($id="")
    {
        // do fun things here
    }

    function add() {
       // do more fun things here
    }

}


How do I get it so that both requests like this work:

www.site.com/mycontroller/index/3<-- this works by default, sets $id value to 3

www.site.com/mycontroller/3 <-- this fails with 404, since '3' is not valid action

www.site.com/mycontroller/add <-- this works as expected

www.site.com/mycontroller <-- this will work and load index action by default


This is simply because I don't want to use url like www.site.com/cars/index/3 as I think having index at the end of every section looks funny. So www.site.com/cars/3 is what I want to work.


Thanks!


  upgrading from 1.3.3 to 1.5.4
Posted by: El Forum - 10-19-2007, 10:20 AM - No Replies

[eluser]mdg5w[/eluser]
I just upgraded this morning and it seems like for the most part my site is still working.

However,

http://mysite.com/controllerName/

doesn't work. but.

http://mysite.com/index.php/controllerName/

does.

This is only the case for 1 controller.

Any thoughts?


  How to include pre-written libraries?
Posted by: El Forum - 10-19-2007, 09:12 AM - No Replies

[eluser]jahboite[/eluser]
Hello!

Bit of background:
I'm developing an application for facebook. Before attempting this, I'd never written any php and I'm not completely au fait with javascript. I started development on my app from scratch using notepad (well Textpad actually, but manually is what I mean) and then I found out that other people were using php frameworks like drupal and CodeIgnitor. I couldn't believe I'd missed such a thing.

Yesterday I decided to get hold of CI and started learning about it, playing with it and started to recreate my application using it. It looks like a great bit of kit and I was hooked once I'd watched the tutorial vids.

Facebook provides some php classes and I needed to work out how to use these with CI. At first, I just php included them, but was getting some undefined index notices. Did a bit of research and decided to load the facebook classes as plugins. This seems to have worked nicely and CI stopped complaining about the index.

Then I was reading about CI libraries and I thought I'd have a go at loading the facebook classes as libraries instead. I had to capitalise the filenames, and I also separated an existing php file into two separate php files, one for each of two classes, naming the files the same as the contained class...

Trouble was CI started warning me about missing arguments for the functions as they were instantiated. I played and fiddled, but realised I was fumbling around in the dark so I went back to loading as plugins.

My question is, given an external library, what's the proper way to use them within CI such that one doesn't have to rewrite them or make major mods?


  DB Query Returns
Posted by: El Forum - 10-19-2007, 08:11 AM - No Replies

[eluser]Daburn[/eluser]
Hi Guys

I'm trying to become acquainted with CodeIgniter but now facing a problem with the returns of my DB query. I want to give all the values with no content the value "keine Angaben". Because else, the table cells with no content won't be draw.

My Model:

Code:
function list_stocks() {
            $query = $this->db->query('SELECT * FROM stocks');
            foreach ($query->result() as $value) {
                if (strlen($value) == 0) $value = "keine Angaben";
            }
            return $query;
        }

My Controller:
Code:
$this->load->model('Home_model','', TRUE);
$data['query'] = $this->Home_model->list_stocks();
                    
$this->load->view('loader', $data);

Obviously, $query returns an object, but I'm not sure how to realise it else without addressing each result separately with:
Code:
if ($row->name == "") $row->name = "&nbsp;"
if ($row->price == "") $row->price = "&nbsp;"

Thanks a lot,
Daburn


  [solved] validation class - callback functions
Posted by: El Forum - 10-19-2007, 06:57 AM - No Replies

[eluser]obiron2[/eluser]
Hi guys,

I am trying to extend my knowlege of some of the more advanced functions in CI.

I have a form which requires a start and end date, populated as 3 fields per date Sday,Smth,Syr and Eday,Emth,Eyr

I would like to use the validation class to do the following:

Validate that each field is populated and is numeric and no more than 2 digits long - easy - 'required|trim|numeric|max_length[2]'.

Validate that when Sday,Smth,Syr are combined together they form a valid date

Validate that the start date is before the end date

Validate that the start date is after a date pulled from the database

I don't really understand what is happening with $rules[] and $fields[] and what the validation class then does with them

Can anyone point me in the right direction on how to combine fields together in validation rules.



Thanks

obiron


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

Username
  

Password
  





Latest Threads
shortcodes for ci4
by xsPurX
1 hour ago
Array to HTML "Table"
by paulkd
9 hours ago
TypeError when trying to ...
by b126
10 hours ago
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
v4.5.1 Bug Fix Released
by lokman
04-16-2024, 02:12 PM
problem with textarea
by Nitin Arora
04-16-2024, 05:07 AM

Forum Statistics
» Members: 84,577
» Latest member: 68gamebaigr
» Forum threads: 77,558
» Forum posts: 375,897

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB